[英]CSS - Parent div width should depend on second child
I am new to HTML/CSS, I am trying to achieve a particular scenario:我是 HTML/CSS 的新手,我正在尝试实现一个特定的场景:
I am not sure if it can be achieved using only CSS.我不确定是否可以仅使用 CSS 来实现。 Would really appreciate your help with this.
非常感谢您的帮助。
Thanks in advance.提前致谢。
For the container to use the content as a width reference it's possible and it's called "shrinkwrapping" visit this thread for more detail.对于使用内容作为宽度参考的容器,它被称为“收缩包装”,请访问此线程以获取更多详细信息。
For the label div, you can use this CSS property .对于标签 div,您可以使用此 CSS 属性。
So the answer to your question, yes it's possible.所以你的问题的答案是,是的,这是可能的。
Implemented using flex in CSS.在 CSS 中使用 flex 实现。 Working demo can be found here.
可以在此处找到工作演示。 'https://codepen.io/shrdz_yadav/pen/rNLNPQE'
'https://codepen.io/shrdz_yadav/pen/rNLNPQE'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.