简体   繁体   English

如何相对于另一个 div 容器对齐 div 容器?

[英]How do I align a div container relative to another div container?

I have a little info board that contains two div containers, one is a dynamicly wide list and the other ist a static iframe.我有一个包含两个 div 容器的小信息板,一个是动态宽列表,另一个是静态 iframe。 They should be both aligned to the right for layout reasons.出于布局原因,它们都应该向右对齐。 My question is: how do I implement that?我的问题是:我该如何实现?

 #anwesendheitsliste_container { font-size: 22px; position: absolute; float: right; margin-right: 10px; right: 3px; top: 170px } .toc_title { text-align: center } #list { text-align: start } #wwidget { position: relative; top: 250px; /* right: 350px;*/ margin-right: 10px; margin: 10px; }
 <div id="anwesendheitsliste_container"> <p class="toc_title">Anwesende Wenigkeiten&nbsp&nbsp</p> <ul class="toc_list"> <div id="list"> <li>Lorem Ipsum</li> <li>Dolor sit Amet</li> </div> </ul> </div> <div id="wwidget"> <iframe src="http://info-board.fks.tuhh.de/site/wwidget.html" height="220px" width="220px" frameborder="0" seamless></iframe> </div>

screenshot截屏

use this code使用此代码

 .right-align{ display: flex; flex-direction: column; align-items: end; }
 <div class="right-align"> <div id="anwesendheitsliste_container"> <p class="toc_title">Anwesende Wenigkeiten&nbsp&nbsp</p> <ul class="toc_list"> <div id="list"> <li>Lorem Ipsum</li> <li>Dolor sit Amet</li> </div> </ul> </div> <div id="wwidget"> <iframe src="http://info-board.fks.tuhh.de/site/wwidget.html" height="220px" width="220px" frameborder="0" seamless></iframe> </div> </div>

If you just want both on the right you can try this, hope it helps, here I am not adding anything in the code, just changing the div that wraps the iframe如果你只想要两个都在右边,你可以试试这个,希望它有帮助,在这里我没有在代码中添加任何东西,只是改变包装 iframe 的 div

 #anwesendheitsliste_container { font-size: 22px; position: absolute; float: right; margin-right: 10px; right: 3px; top: 170px } .toc_title { text-align: center } #list { text-align: start; } #wwidget { position: relative; /* right: 350px;*/ margin-right: 10px; margin: 10px; }
 <div id="anwesendheitsliste_container"> <p class="toc_title">Anwesende Wenigkeiten&nbsp&nbsp</p> <ul class="toc_list"> <div id="list"> <li>Lorem Ipsum</li> <li>Dolor sit Amet</li> </div> </ul> <div id="wwidget"> <iframe src="http://info-board.fks.tuhh.de/site/wwidget.html" height="220px" width="220px" frameborder="0" seamless></iframe> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM