猿问

子元素宽度如何撑开父元素宽度

如图这是一个横向滚动栏,子元素高度会自动撑开父元素的高度,但是好像子元素宽度不能自动撑开父元素的宽度,如何使用css使子元素宽度可以自动撑开父元素宽度,避免计算父元素的宽度。

烙印99
浏览 3169回答 1
1回答

桃花长相依

<!doctype html><html><head>&nbsp; &nbsp; <meta charset="utf-8">&nbsp; &nbsp; <title>无标题文档</title></head><body>&nbsp; &nbsp; <style>&nbsp; &nbsp; &nbsp; &nbsp; .box{width:300px;height:100px;background:#000;}&nbsp; &nbsp; &nbsp; &nbsp; .inner{white-space:nowrap;width:auto;display:inline-block;zoom:1;*display:inline;margin:10px 0 0 10px;background:#FC9;}&nbsp; &nbsp; &nbsp; &nbsp; .inner span{display:inline-block;width:80px;height:100px;margin:0 10px;background:#dd4215;}&nbsp; &nbsp; </style>&nbsp; &nbsp; <div class="box">&nbsp; &nbsp; &nbsp; &nbsp; <div class="inner">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span></span>&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </div></body></html>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答