全宽输入在div

编程入门 行业动态 更新时间:2024-10-12 05:44:44
本文介绍了全宽输入在div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有可能,在 width:calc(...)或 flex 具有输入 #what 以使用其父的全部宽度 #b ?

Is it possible, without width: calc(...) nor flex (for legacy support) to have the input #what to use full width of its parent #b ?

请注意:以全屏方式运行代码段,并重新调整浏览器 width 的大小以查看正在执行的媒体查询。

Note: Run the code snippet in full-screen and re-dimension the browser width to see the media query in action.

* { padding: 0; margin: 0; } #a { float: left; background-color: red; width: 150px; } #b { background-color: blue; } #c { float: right; width: 40%; background-color: yellow; } #icon { background-color: black; width: 20px; display: inline-block; } #what {}@media (max-width: 600px) { #c { width: 100%; } }

<div> <div id="a">a float</div> <div id="c">c float or not</div> <div id="b"> <div id="icon">s</div> <input id="what" value="Blah" /> </div> </div>

推荐答案

您可以使用 CSS表,因为您不想使用 calc() flexbox ,

You can use CSS tables because you don't want to use calc() nor flexbox,

由于我忘记了媒体查询,我使用的评论中给出的代码 @GCyrillus

Since I forget the media query I used the code given in comments by @GCyrillus

* { margin: 0; padding: 0; box-sizing:border-box } .table { display: table; width: 100%; table-layout: fixed; } #a { background-color: red; width: 150px; display: table-cell } #b { background-color: blue; display: table; width: 100% } #c { width: 40%; background-color: yellow; display:table-cell } #icon { background-color: green; display: table-cell; } #what { display: table-cell; vertical-align: top; width: 100% } @media (max-width: 600px) { #c { width: 100%; display: table-caption; caption-side: bottom; } }

<div class="table"> <div id="a">a float</div> <div id="b"> <div id="icon">s</div> <input id="what" value="Blah" /> </div> <div id="c">c float or not</div> </div>

更多推荐

全宽输入在div

本文发布于:2023-11-23 04:10:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620036.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!