[英]Full width gallery with an image in the center
我必須創建一個寬度為“無盡”的畫廊,每張幻燈片的寬度為940px
,網站中心的width:940px;margin: 0 auto 0;
如何強制當前圖片准確位於網站中心?
這是我的嘗試:
1個
#gallery {
white-space: nowrap;
text-align: center;
}
2
#gallery {
width: 100%;
text-align: left;
}
請注意,我可以使用javascript解決此布局問題,我正在尋找使用純 CSS的解決方案。
謝謝。
這可能會有所幫助-以下CSS將div放置在中心/中間(水平和垂直),而不是像align:center那樣僅水平居中。
#centerdiv {
position:absolute;
top:50%;
left:50%;
width:940px;
height:300px;
margin-top:-150px; /* Half your height */
margin-left:-470px; /* Half your width */
background:#333; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.