html - 浏览器呈现的宽度和高度与指定的 css 不同?

标签 html css

在我的 html 页面中,我有 headerleftpane 作为 divhedaer 的高度是116pxleftpane 的宽度是181px。当我使用 chrome-developer-tool 检查我的页面时,它显示高度和宽度分别为 98.36px165.41px 而不是原来指定的在 CSS 中。

下图显示了高度的问题 height problem

下图显示了宽度问题。 width problem

这是相关的CSS

.dashboard-header {
  background: #000000;
  height: 116px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
}
.dashboard-leftpane {
  width: 181px;
  background: #000000;
  height: 100%;
}

对应的html代码

  <div class="input-search">
    <img class="imgage-search" src="search.svg" alt="Grace Logo">
    <input type="text" name="" value="" placeholder="" style="border:none; background: #FAFAFA; flex-grow: 2;">
    <img class="imgage-search" src="filter.svg" alt="">
  </div>


  <div class="profile-menu">
    <span class="profile-menu-name">USER</span>
    <img src="arrow_drop_down.svg" alt="">
  </div>

<div class="dashboard-leftpane">

    <div class="giraffe-list">
      <div class="giraffe-list-item">
          <span class="giraffe-item-name">ITEM1</span>
      </div>

      <div class="giraffe-list-item">
          <span class="giraffe-item-name">ITEM2</span>
      </div>

      <div class="giraffe-list-item">
          <span class="giraffe-item-name">ITEM3</span>
      </div>

      <div class="giraffe-list-item">
          <span class="giraffe-item-name">ITEM4</span>
      </div>

      <div class="giraffe-list-item">
          <span class="giraffe-item-name">ITEM5</span>
      </div>
    </div>

</div>

最佳答案

好吧,不知道这是否可行,但请确保您的 div 上有 box-sizing: border-box

如果这不能解决问题,可能是因为 display: flex;

有必要使用display: flex;吗?

关于html - 浏览器呈现的宽度和高度与指定的 css 不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42558036/

相关文章:

javascript - 展开和折叠元素以及从 JavaScript 中删除静态文本

html - CSS曲线波浪背景

php - header 或 session 问题

HTML 输入按钮 css-height 在 Safari 和 Chrome 上不起作用

php - 如何动态地将列表分成不同的div

css - 如何修复单行文本下的额外边距(仅在 Firefox 中)?

javascript - 修复了容器 Div 中的 Div,使其仅在到达浏览器顶部时向下滚动

html - 容器部分 - 如何将其居中对齐?

html - 围绕字符串的中间字符居中文本

javascript - 无法在 jquery 中选择不透明度?