Heim  >  Artikel  >  Web-Frontend  >  我给DIV加了个padding:15px 结果他的边框错位了_html/css_WEB-ITnose

我给DIV加了个padding:15px 结果他的边框错位了_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:26:151305Durchsuche

想让DIV里面的内容靠内部一些(不贴边),用了padding结果DIV边框溢出了。

        .PhotoP        {            width:100%; height:160px; border-bottom:1px dashed gray; padding:15px;        }        <div style=" width:970px; height:400px;">              <div class="PhotoP">                   sdadas              </div>        </div>


回复讨论(解决方案)

看截图右下角。。。
那个底部虚线右边溢出了一些,求解决

width:100%去掉

用外层的div的margin比较好一点。

width:100%去掉
为什么100%去掉就好了?确实好了
但是搞不懂不给DIV加width100%,DIV下边虚线宽度依旧是100%宽度


width:100%去掉
为什么100%去掉就好了?确实好了
但是搞不懂不给DIV加width100%,DIV下边虚线宽度依旧是100%宽度

这个应该和盒模型有关系~


width:100%去掉
为什么100%去掉就好了?确实好了
但是搞不懂不给DIV加width100%,DIV下边虚线宽度依旧是100%宽度

div这个标签本身就是块状元素,会独占一行的,所以你不写宽度,会按外容器的宽度显示~

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn