Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 图像不适合容器并在div外部运行_Css - Fatal编程技术网

Css 图像不适合容器并在div外部运行

Css 图像不适合容器并在div外部运行,css,Css,我有一个内容(div),其中必须部署映像网格,但不幸的是映像网格不适合容器,并且它用完了div。我已将代码上载到JSFIDLE上: 我的Html代码: <div id="contentwrap"> <div id="content"> <p>Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a documen

我有一个内容(div),其中必须部署映像网格,但不幸的是映像网格不适合容器,并且它用完了div。我已将代码上载到JSFIDLE上:

我的Html代码:

<div id="contentwrap">
<div id="content">
<p>Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language. While most often used to change the style of web pages and user interfaces written in HTML and XHTML, the language can be applied to any kind of XML document, including plain XML, SVG and XUL.</p>

<div class="MyBox">
    <ul id="grid">
       <li><a href="newgrid.html"><img src="http://www.nerdorturd.com/wp-content/uploads/2014/10/css_cascading_style_sheet.jpg"></a></li>
       <li><a href="newgrid.html"><img src="http://www.nerdorturd.com/wp-content/uploads/2014/10/css_cascading_style_sheet.jpg"></a></li>
       <li><a href="newgrid.html"><img src="http://www.nerdorturd.com/wp-content/uploads/2014/10/css_cascading_style_sheet.jpg"></a></li>
       <li><a href="newgrid.html"><img src="http://www.nerdorturd.com/wp-content/uploads/2014/10/css_cascading_style_sheet.jpg"></a></li>  
    </ul>                                    
</div>       
</div>
</div>

层叠样式表(CSS)是一种样式表语言,用于描述用标记语言编写的文档的外观和格式。虽然最常用于更改用HTML和XHTML编写的网页和用户界面的样式,但该语言可以应用于任何类型的XML文档,包括纯XML、SVG和XUL


这似乎是一个“
clearfix
”问题。将此添加到CSS中:

#content:after {
    content: "";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
}
最终,您可以将其更改为一个类,并在任何有此问题的地方实现它。

simple add

 height:auto;
overflow:auto;
class=MyBox

也添加此样式

.MyBox {
display: inline-table;
}

查看更新的小提琴

新增
溢出:自动
#内容

CSS:

#content {
    background: #FFF8DC;
    border-radius: 10px;
    border: 1px solid #ebebeb;
    margin: 5px;
    padding: 10px;
    overflow:auto;
    display:block;
}

小提琴出了什么问题?一切都很完美,因为它起作用了。我面临的另一个问题是图片上的标题。我想在div内的每幅图片下面都加上标题。你能装上小提琴吗?但你没有提到你会提到的问题before@SatishGupta它非常简单,有一个尝试,你只需要添加跨度不是我要找的。我不得不在盒子里放上标题。我试过这样做:但它不支持旧浏览器。