我的網站 http://cynthiawoodyardlandscapedesign.com/ 有幾個問題只存在於Firefox中。Firefox絕對定位失敗
當點擊主頁上的圖像時,兩側出現的允許用戶更改圖片的箭頭位於頁面頂部。持有箭頭的div應該具有100%的高度,我甚至將!important
添加到CSS。只有Firefox不能正確顯示。
我的CSS(http://cynthiawoodyardlandscapedesign.com/css/main.css):
#sheet {
width: 100%;
height: 100%;
position: fixed;
overflow: hidden;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.8);
display: table;
z-index: 150;
}
#popover {
margin: auto;
background: rgba(0,0,0,0);
text-align: center;
padding: 10px;
border: 1px solid black;
position: relative;
display: table-cell;
vertical-align: middle;
}
#popover-image {
height: 70%;
border: 10px solid white;
}
#exit {
position: absolute;
top: 50px;
color: white;
font-size: 20px;
font-weight: bold;
width: 100%;
text-align: center;
z-index: 300;
font-family: sans-serif;
}
#next-image, #previous-image { cursor: pointer; background: transparent; }
#next-image::-moz-selection, #previous-image::-moz-selection,
#next-image::selection, #previous-image::selection { background: rgba(0,0,0,0); }
#leftArrow, #rightArrow {
width: 20%;
height: 100% !important;
position: absolute;
z-index: 200;
display: table;
background: transparent;
top: 0;
}
#leftArrow { left: 0; } #rightArrow { right: 0; }
#next-image {
display: table-cell !important;
vertical-align: middle;
margin: 0 auto;
text-align: center;
line-height: 50px;
font-size: 50px;
-webkit-text-stroke: 1px black;
-moz-text-stroke: 1px black;
height: 50px;
width: 50px;
color: white;
}
#previous-image {
display: table-cell !important;
vertical-align: middle;
margin: 0 auto;
text-align: center;
line-height: 50px;
font-size: 50px;
-webkit-text-stroke: 1px black;
-moz-text-stroke: 1px black;
height: 50px;
width: 50px;
color: white;
}
我的HTML(http://cynthiawoodyardlandscapedesign.com/default.php):
<div id="sheet">
<div id="exit">Exit</div>
<div id="popover">
<div id="leftArrow"><div id="previous-image" onclick="previous()">«</div></div>
<img src="watermark.php?src=images/main1.jpg&x=0&y=420&opactity=50" id="popover-image" onclick="close()" />
<div id="rightArrow"><div id="next-image" onclick="next()">»</div></div>
</div>
</div>
,我試過其他瀏覽器(IE除外;我在Mac上)顯示頁面正確。
編輯:我有更多的Firefox問題。
在http://cynthiawoodyardlandscapedesign.com/photography.php的頁面顯示了許多照片是在<td>
標籤和img
之後,但在</td>
之前存在一個具有絕對位置,top: 10px;
在每一個瀏覽器(IE8甚至!!)這是行不通的跨度正確。
我的HTML頁面:
<table id="photos">
<tr>
<td><img src="images/photo-thumbs/garden.jpg" /><span>Gardens</span></td><td><img src="images/photo-thumbs/trees.jpg" /><span>Trees</span></td><td><img src="images/photo-thumbs/shrubs.jpg" /><span>Shrubs</span></td><td><img src="images/photo-thumbs/perennials.jpg" /><span>Perennials</span></td>
</tr>
<tr>
<td><img src="images/photo-thumbs/annuals.jpg" /><span>Annuals</span></td><td><img src="images/photo-thumbs/tropicals.jpg" /><span>Tropicals</span></td><td><img src="images/photo-thumbs/bulb.jpg" /><span>Bulbs</span></td><td><img src="images/photo-thumbs/containers.jpg" /><span>Containers</span></td>
</tr>
<tr>
<td><img src="images/photo-thumbs/fruit.jpg" /><span>Fruit</span></td><td><img src="images/photo-thumbs/animals.jpg" /><span>Creatures</span></td><td><img src="images/photo-thumbs/people.jpg" /><span>People</span></td><td><img src="images/photo-thumbs/travel.jpg" /><span>Travel</span></td>
</tr>
</table>
#photos td {
width: 192px;
height: auto;
position: relative;
border-right: 5px solid transparent;
}
#photos td img { width: 100%; border: 1px solid gold; }
#photos td span {
position: absolute;
top: 10px;
left: 0;
width: 100%;
text-align: center;
background: rgba(0,0,0,0.4);
padding-top: 2px;
padding-bottom: 2px;
color: #f0f0f0;
font-weight: bold;
font-family: "Source Sans Pro", sans-serif;
display: none;
}
幾乎可以肯定這是由於您使用的顯示的':表' - 過去我遇到過很多問題,一些瀏覽器需要在display:table-cell之外使用'display:table-row'的另一個包裝元素。爲什麼不使用'position:absolute;頂部:45%;右:30像素'或類似的東西,而不是黑客一個桌子般的佈局?你也可以做'頂部:50%; margin-top: - [arrowHeight/2];'讓箭頭正好在中間。 – 2013-02-11 00:25:06
謝謝,這個答案工作得很好。 – gtr123 2013-02-13 01:18:52
@afterimagedesign請看看我的答案,並讓我知道如果有任何問題或我滯後於某些地方。 – w3uiguru 2013-02-18 18:38:57