2015-01-15 66 views
0

我想將按鈕放在右下角。如何強制樣式HTML元素?

這是我曾嘗試:

  • 我嘗試使用!important,但它沒有任何效果

CSS:

#back-to-top { 
    position: fixed !important; 
    right:400 !important; 
    bottom: 17!important; 
    color: black; 
    border: #90bc26 solid 1px; 
    border-radius: 5px; 
    padding: 5px; 
} 

這是我看到檢查我的按鈕時, :

enter image description here

正如您所見,我的rightbottom樣式被覆蓋,我該如何解決這個問題?

+2

您的右側和底部屬性需要單位,比如'400px'或' 400em'。只有0不需要單位 – mikelt21 2015-01-15 17:54:21

+2

那些感嘆號圖標可能會說一些有用的東西 – Huangism 2015-01-15 17:55:59

回答

6

你忘了使用計量單位像px%em的右側和底部:

right:400px; 
bottom: 17px; 

無需使用!important

+1

你說得對。現在是工作。謝謝。 – iori 2015-01-15 17:56:46

-2

#idname 

更改CSS選擇

tag#idname 

所以,你的選擇會是這樣

button#back-to-top 
+1

我真的無法讓你... – 2015-01-15 17:58:10

+0

粘貼我的體驗。有時我會使用不像其他選擇器那樣精確的選擇器,並且屬性會被覆蓋。這種情況在少數情況下發生在標籤的ID上。 – 2015-01-15 20:11:52