边框超出了 div。

huangapple go评论96阅读模式
英文:

Border goes outside div

问题

  1. 我有一个问题,一个 div 元素超出了父元素 (div.navigation-view)。
  2. index.html

<div class="navigation-view">
<div class="nav-content">

  1. &lt;/div&gt;

</div>

navigation.sass

  1. $nav-bar-height: 50px
  2. $nav-bar-link-color: white
  3. body
  4. margin: 0
  5. padding: 0
  6. div.navigation-view
  7. background-color: black
  8. height: $nav-bar-height
  9. width: 100vw
  10. position: fixed
  11. top: 0
  12. div.nav-content
  13. display: inline-block
  14. height: 100%
  15. max-height: 100% !important
  16. width: 60%
  17. border: 1px solid red
  1. 图片:
  2. [图中边框超出另一个 div][1]
  3. [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

  1. &lt;div class=&quot;navigation-view&quot;&gt;
  2. &lt;div class=&quot;nav-content&quot;&gt;
  3. &lt;/div&gt;
  4. &lt;/div&gt;

navigation.sass

  1. $nav-bar-height: 50px
  2. $nav-bar-link-color: white
  3. body
  4. margin: 0
  5. padding: 0
  6. div.navigation-view
  7. background-color: black
  8. height: $nav-bar-height
  9. width: 100vw
  10. position: fixed
  11. top: 0
  12. div.nav-content
  13. display: inline-block
  14. height: 100%
  15. max-height: 100% !important
  16. width: 60%
  17. border: 1px solid red

Image:

Image with border going outside the other div

答案1

得分: 1

box-sizing: border-box 加入到你的样式中:

navigation.sass

  1. *
  2. box-sizing: border-box
英文:

Add box-sizing: border-box to your styles:

navigation.sass

  1. *
  2. box-sizing: border-box

huangapple
  • 本文由 发表于 2023年4月4日 03:09:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75922980.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定