英文:
Border goes outside div
问题
我有一个问题,一个 div 元素超出了父元素 (div.navigation-view)。
index.html
<div class="navigation-view">
<div class="nav-content">
</div>
</div>
navigation.sass
$nav-bar-height: 50px
$nav-bar-link-color: white
body
margin: 0
padding: 0
div.navigation-view
background-color: black
height: $nav-bar-height
width: 100vw
position: fixed
top: 0
div.nav-content
display: inline-block
height: 100%
max-height: 100% !important
width: 60%
border: 1px solid red
图片:
[图中边框超出另一个 div][1]
[1]: https://i.stack.imgur.com/t3aMN.png
英文:
I have a problem with a div which goes outside the parent element (div.navigation-view).
index.html
<div class="navigation-view">
<div class="nav-content">
</div>
</div>
navigation.sass
$nav-bar-height: 50px
$nav-bar-link-color: white
body
margin: 0
padding: 0
div.navigation-view
background-color: black
height: $nav-bar-height
width: 100vw
position: fixed
top: 0
div.nav-content
display: inline-block
height: 100%
max-height: 100% !important
width: 60%
border: 1px solid red
Image:
答案1
得分: 1
box-sizing: border-box 加入到你的样式中:
navigation.sass
*
box-sizing: border-box
英文:
Add box-sizing: border-box to your styles:
navigation.sass
*
box-sizing: border-box
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论