2012-10-03 28 views
0

我想讓這樣的事情:CSS stickied登錄按鈕頂端

http://puu.sh/1b5jU

所以我做的東西在這裏,但它看起來並不相同的所有畫面上還是在其內部引導容器,960像素:

http://justxp.plutohost.net/slyfiles/index.html

它看起來像朋友的屏幕上的內容:

http://puu.sh/1b51h

這是它的CSS所有

.delogin { 
width: 70px; 
height: 20px; 
background-color: #443b28; 
-webkit-border-radius: 0px 0px 7px 7px; 
border-radius: 0px 0px 7px 7px; 
position: absolute; 
margin-left: 51%; 
-webkit-transition: all 100ms ease-in-out; 
     -moz-transition: all 100ms ease-in-out; 
     -ms-transition: all 100ms ease-in-out; 
     -o-transition: all 100ms ease-in-out; 
     transition: all 100ms ease-in-out; 
} 

.login { 
width: 70px; 
height: 20px; 
background-color: #443b28; 
-webkit-border-radius: 0px 0px 7px 7px; 
border-radius: 0px 0px 7px 7px; 
position: absolute; 
margin-left: 51%; 
right: 0px; 
-webkit-transition: all 100ms ease-in-out; 
     -moz-transition: all 100ms ease-in-out; 
     -ms-transition: all 100ms ease-in-out; 
     -o-transition: all 100ms ease-in-out; 
     transition: all 100ms ease-in-out; 
} 
.login:hover{ 
width: 70px; 
height: 20px; 
background-color: #443b28; 
-webkit-border-radius: 0px 0px 7px 7px; 
border-radius: 0px 0px 7px 7px; 
position: absolute; 
margin-left: 51%; 
top: 5px; 
-webkit-transition: all 100ms ease-in-out; 
     -moz-transition: all 100ms ease-in-out; 
     -ms-transition: all 100ms ease-in-out; 
     -o-transition: all 100ms ease-in-out; 
     transition: all 100ms ease-in-out; 
} 

#login { 
float: right; 
margin-right: 11px; 
font-weight: bold; 
font-size: 11px; 
color: #fff; 
-webkit-transition: all 100ms ease-in-out; 
     -moz-transition: all 100ms ease-in-out; 
     -ms-transition: all 100ms ease-in-out; 
     -o-transition: all 100ms ease-in-out; 
     transition: all 100ms ease-in-out; 
    } 
    #lock { 
    background-image: url("../img/lock.png"); 
    width: 13px; 
    height: 10px; 
    position: absolute; 
    top: 5px; 
    left: 7px; 
-webkit-transition: all 100ms ease-in-out; 
     -moz-transition: all 100ms ease-in-out; 
     -ms-transition: all 100ms ease-in-out; 
     -o-transition: all 100ms ease-in-out; 
     transition: all 100ms ease-in-out; 
    } 

HTML:

<div class="delogin"> 
     <div class="login"> 
      <div id="lock"></div> 
      <span id="login"><a href="login.php">LOGIN</a></span> 
     </div> 
    </div> 

這是如果需要整個HTML \ CSS:

http://pastebin.com/qJkA99nW

問題:

如何將登錄按鈕粘貼到960像素網格系統內的右側,而不使菜單將任何像素移動到任何一側?並在所有屏幕和瀏覽器上使它看起來有點相似或相似。

我從來沒有見過這樣的問題或教程如何使這樣的粘性按鈕。

謝謝!

+0

我竭力要明白你的問題的位置,你也許可以彈出你有什麼成的jsfiddle? – JDandChips

+0

我希望該按鈕能夠在不移動整個菜單的情況下使用聯繫人菜單項,並且可以在所有瀏覽器或屏幕尺寸中位於同一位置。 – Jony

回答

2

添加position: relative.container

.container { 
    margin-left: auto; 
    margin-right: auto; 
    position: relative; /* this */ 
} 

,然後設置按鈕

.delogin { 
    -moz-transition: all 100ms ease-in-out 0s; 
    background-color: #443B28; 
    border-radius: 0 0 7px 7px; 
    height: 20px; 
    margin-left: 51%; 
    position: absolute; 
    right: 0; /* this */ 
    width: 70px; 
} 
+0

是的,但使屏幕變小,按鈕將移動到一邊,對我的朋友來說,現在就在twitter菜單上方。 – Jony

+0

剛剛在FF和Chrome中檢查 - 它保持在「聯繫人」 –

+0

這應該工作,但在http://justxp.plutohost.net/slyfiles/index.html容器被設置爲'position:relative * zoom:1 ' - 這會導致按鈕在屏幕上移動 – JDandChips