html - 在 html 中使用 css 的 boxsize

标签 html css

我在调整盒子大小方面遇到了一些问题。 代码如下:

<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
      .wrapper { 

        text-align: center; 
      } 

      #bubble { 
        display: inline; 

        -moz-border-radius: 15px;
        border-radius: 15px;
        margin: 5px;
        width: 100px; 
        height: 100px; 
        position: relative; 
        border: solid;
        border-width: 1px; 
        background-color: #999999;
        font-name: arial;
      }
    </style>

  </head>
  <body>
    <div class="wrapper"> 
      <div id="bubble">Box 6</div> 
      <br clear="all"> 
      <div id="bubble">Box 5</div> 
      <div id="bubble">Box 5</div> 
    </div>

  </body>
</html>

所以我的问题是,我希望这些框的大小为 100px x 100px,如样式中所述。但是 chrome 以某种方式向我显示了 42px x 19px 大小的框。

可能我遗漏了一件简单的事情。 -.-°

感谢您的帮助。

最佳答案

  1. 您不能为多个元素使用 id,将其切换为 class。
  2. 您应该将显示更改为内联 block 或 block ,以使宽度/高度起作用。

希望对您有所帮助。

 .wrapper { 

    text-align: center; 
  } 

  .bubble { 
    display: inline-block; 

    -moz-border-radius: 15px;
    border-radius: 15px;
    margin: 5px;
    width: 100px; 
    height: 100px; 
    position: relative; 
    border: solid;
    border-width: 1px; 
    background-color: #999999;
    font-name: arial;
  }

这是一个FIDDLE

关于html - 在 html 中使用 css 的 boxsize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24811864/

相关文章:

php - 使用 php 创建一个调用 php 函数的按钮

jquery - 如何垂直翻转进度条?

javascript - 幕后发生了什么,这是正确的方法吗? (通过 Javascript 修改 DOM)

html - 粘性 header 始终可见?

html - 使用 Lightbox 2 对图像的 CSS 悬停效果

css - 伪元素 :before absolute position issue in IE9 and Firefox, Chrome 可以

html - 在一个 div 中居中多个 <p> 标签

javascript - 从多个下拉列表中获取值

html - 具有全宽标题和均匀间隔的子项的 Flexbox

html - 如何让 TABLE 增长到与其容器相同的高度? (或者,与 IE JavaScript 缓慢作斗争)