2013-06-24 25 views
0

CSS:Firebug固定相同的CSS?

.list-a .desc-fix { 
    width: 180px; 
    margin: 0px auto; 
    position: relative; 
} 
.list-a .desc { 
    background: url("../images/trans_black.png") repeat; 
    display: block; 
    font-family: arial; 
    font-size: small; 
    height: 18px; 
    margin: 3px 0 0 50px; 
    overflow: hidden; 
    padding: 10px; 
    position: absolute; 
    width: 180px; 
    z-index: 3; 
    right:30px; 
    left:30px 
} 

HTML:

<span class="desc-fix"> 
    <span class="desc"> 
     <h4>Text A</h4> 
     <h5>Text B</h5> 
    Long text long text long text Long text long text long text Long text long text long text Long text long text long text Long text long text long textLong text long text long text Long text long text long text 
    </span> 
</span> 

以上是我的代碼對齊絕對定位跨度中間對齊。

但是當我加載頁面時,它並沒有在中間對齊。

當我改變(不是真正的改變,我認爲)的任何CSS的任何事情,並通過螢火蟲改回原來的價值它對齊中間。任何想法,發生了什麼?

+1

哪裏是你的css代碼? – falguni

+0

你的html代碼中的'list-a'在哪裏 – Aravind30790

+0

@falguni我可以在問題頂部看到我的css代碼 –

回答

1

你可以試試下面的代碼,在類內包裝的跨度。檢查此JSFiddle

.list-a .desc-fix { 
    width: 100%; 
    height: 100%; 
} 
.list-a .desc { 
    background: url("../images/trans_black.png") repeat; 
    display: block; 
    font-family: arial; 
    font-size: small; 
    margin: 3px 0 0 50px; 
    padding: 10px; 
    max-width:300px; 
    max-heigtht: 400px; 
    width: 100%; 
    height: 100%; 
} 
.list-a { 
    width:300px; 
    height:400px; 
    margin: 0px auto; 
} 
+0

我設法實現了我的目標。感謝幫助。 –

1

你應該總是你的CSS類鏈接到他們的直接父,如:

.list-a span .desc-fix {) 
.list-a span .desc {) 
在任何其他瀏覽器

或者只是簡單地

span .desc-fix {} 
span .desc {} 

是否行得通?

編輯:給這個一掄https://stackoverflow.com/a/7720742/2516336

+0

我設法實現了我的目標。感謝幫助。 –