简体   繁体   English

<span>在 div 的右下角</span>

[英]<span> in bottom right corner of div

I want a div looking like this:我想要一个看起来像这样的 div:

+--------------------------------+
| (Chip) (Chiiiiip) (Chipppp)    |
| (Chiiiiiiiiiiiipppp)           |
|                                |
|                           More |   
+--------------------------------+

Similarly the "Less" button when the div is expanded with more number of chips.同样,当 div 用更多筹码展开时,“Less”按钮。

I can't position the "More" button in the bottom right corner.我无法将“更多”按钮放在右下角。 I want to know how to do it.我想知道怎么做。

If your container has position:relative you can use absolute positioning in a child element.如果你的容器有position:relative你可以在子元素中使用绝对定位。

 .container { width:300px; height:200px; position:relative; padding:10px; border:1px solid red; } .expand { position:absolute; bottom:10px; right:10px; }
 <div class="container"> Text text text Text text text Text text text Text text text Text text text Text text text Text text text <button class="expand">More</button> </div>

Use a div to wrap the content or button and add the CSS styling given below, it should push the content or button to the right side.使用 div 包装内容或按钮并添加下面给出的 CSS 样式,它应该将内容或按钮推到右侧。

.More-div {
 display: flex;
 justify-content: flex-end;
}

Share your CSS codes so that it will be easier to add or modify the CSS styling.共享您的 CSS 代码,以便更轻松地添加或修改 CSS 样式。

For reference I have added snippet.作为参考,我添加了片段。

 .container{ border: 1px solid #000; display: flex; flex-direction: column; } .more-wrapper{ display: flex; justify-content: flex-end; }
 <div class="container"> <div class='text-wrapper'> Text text text Text text text Text text text Text text text Text text text Text text text Text text text <div> <div class='more-wrapper'> <button>More</button> </div> </div>

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

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