• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Frage Scriptcode für PC oder Mobile

Hallo,

Ich nutze folgenden Scriptcode:
Code:
<script type="text/javascript">
var info = document.getElementById("infoBox");
info.style.display = "none";
info.style.position = "absolute";
info.style.zIndex = 999;
info.style.left = "435px";

function buttonShow() {
info.style.display = "";
}
                                        
function buttonHide() {
info.style.display = "none";
}
</script>

Wie bekomme ich es hin, dass z.b. mein IPhone nicht
Code:
info.style.left = "435px";
sondern z.b.
Code:
info.style.left = "10px";
nutzt?
 
Werbung:
Hallo,

Ich nutze folgenden Scriptcode:
Code:
<script type="text/javascript">
var info = document.getElementById("infoBox");
info.style.display = "none";
info.style.position = "absolute";
info.style.zIndex = 999;
info.style.left = "435px";

function buttonShow() {
info.style.display = "";
}
                                       
function buttonHide() {
info.style.display = "none";
}
</script>

Wie bekomme ich es hin, dass z.b. mein IPhone nicht
Code:
info.style.left = "435px";
sondern z.b.
Code:
info.style.left = "10px";
nutzt?

Im Idealfall mit CSS und Mediaqueries.
z-index, position und left haben hier eigentlich nichts zu suchen und sollte per CSS-Klasse definiert werden.
 
Werbung:
So schwer das ich es nicht schaffe...

Ich habe mein Script geändert:
Code:
<script type="text/javascript">
var info = document.getElementById("infoBox");
info.style.display = "none";
/*info.style.position = "absolute";
info.style.zIndex = 999;
info.style.left = "435px";*/
 
function buttonShow() {
info.style.display = "";
}
                                       
function buttonHide() {
info.style.display = "none";
}
</script>

In einer CSS Datei habe ich den Code eingegeben.
Leider wird der CSS Code ignoriert.
Habe ich was falsch gemacht?!
 
So schwer das ich es nicht schaffe...

Ich habe mein Script geändert:
Code:
<script type="text/javascript">
var info = document.getElementById("infoBox");
info.style.display = "none";
/*info.style.position = "absolute";
info.style.zIndex = 999;
info.style.left = "435px";*/
 
function buttonShow() {
info.style.display = "";
}
                                      
function buttonHide() {
info.style.display = "none";
}
</script>

In einer CSS Datei habe ich den Code eingegeben.
Leider wird der CSS Code ignoriert.
Habe ich was falsch gemacht?!

Dem Element #infoBox die Klasse infobox geben ;)
 
Werbung:
Zurück
Oben