我想在頁面上有一個居中的元素,並在右邊顯示了一些信息的另一個元素。我嘗試將元素向右移動,對我來說看起來很不錯,但我有一個很大的顯示。我調整了瀏覽器窗口的大小,並將中心元素向下推,這是我不想要的。我希望它像這個頁面上:http://imgur.com/XVuMBx6,其中圖片容器元素居中,右側的所有鏈接在右側,但是當您使顯示器變小時,沒有任何東西被推下,但是正確的元素只是被移出瀏覽器窗口。 我的CSS是這樣的,#image是我想都集中在div和#info和.sharebutton是什麼,我想它的右邊:CSS將一個元素居中並將另一個元素浮動到其右側?
#image {
max-width: 900px;
display: block;
margin:auto;
position: relative;
}
#info, .sharebutton {
display: inline-block;
float: right;
position: relative;
}
我試着設置一個明確的:既對圖像元素,但由於某種原因,這會將我的#info和.sharebutton元素扭曲到頁面的左側。謝謝。
編輯:我的HTML:
<div id="info">
<ul>
<li>Uploaded: {{time}}</li>
<br>
<li>Views: {{view_count}}</li>
</ul>
<div class="sharebutton">
<a href="#openModal">
<button id="share">Click Me</button>
</a>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Modal Box</h2>
</div>
</div>
</div>
</div>
<article>
<div id="image">
<a href="{{source}}">
<img src="{{source}}" />
</a>
</div>
</article>
你能顯示一些HTML標記嗎? – misterManSam