Javascript-форум (https://javascript.ru/forum/)
-   Элементы интерфейса (https://javascript.ru/forum/dom-window/)
-   -   Style with position fixed JS (https://javascript.ru/forum/dom-window/54214-style-position-fixed-js.html)

Rzaxan 09.03.2015 11:53

Style with position fixed JS
 
Zdravstvuyte.
var x = screen.width;
    var xx = (x-970)/2-15;
    document.getElementById('clock').style.width = xx+'px';



ne rabotaet. #clock position fixed . mojet bit ot etamu??

рони 09.03.2015 12:15

Rzaxan,
может элемента ещё нет?

Rzaxan 09.03.2015 12:49

eta css ko

#clock{
position:fixed;
top:0;
left:0;
height:100%;
background-image:url(../rek/clock.jpg);
background-size:100% 100%;

}

Rzaxan 09.03.2015 13:05

kaqda position bivaet relative rabotaet a tak net

рони 09.03.2015 13:39

Rzaxan,
и что не так?
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
body, html{
   height:100%;
}
 #clock{
position:fixed;
top:0;
left:0;
height:100%;
background-image:url(../rek/clock.jpg);
background-size:100% 100%;
 background-color: #CCCCCC;
}

  </style>
</head>

<body>
  <div id="clock"></div>
 <script>

var x = screen.width;
var xx = (x-970)/2-15;
document.getElementById('clock').style.width = xx+'px';

 </script>
</body>

</html>

Rzaxan 09.03.2015 13:55

Aaa teper rabotal. znacit js kod doljsen posle div-a:) :) :)

рони 09.03.2015 13:59

Цитата:

Сообщение от Rzaxan
js kod doljsen posle div-a

Цитата:

Сообщение от рони
элемента ещё нет

:write:


Часовой пояс GMT +3, время: 08:52.