- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
带内边距的 div 不能小于其内边距所允许的大小。
这是预期的行为吗?如果是这样,我们该如何处理?
div {
display: inline-block;
height: 50px;
width: 1px; /* Why won't it? */
padding: 10px;
box-sizing: border-box;
background: grey;
animation: animate-width 4s ease-in-out infinite;
}
@keyframes animate-width {
0% { width: 50px }
50% { width: 1px }
100% { width: 50px }
}
<div></div>
<div style="padding: 0"></div>
最佳答案
一个解决方案是考虑一个父元素,您可以强制其宽度等于 0 并 overflow hidden :
.parent {
display: inline-block;
animation: animate-width 4s ease-in-out infinite;
background:red;
overflow:hidden;
}
.parent > div {
height: 50px;
padding: 10px;
box-sizing: border-box;
background: grey;
min-width:0;
width:100%;
}
@keyframes animate-width {
0% {
width: 50px
}
50% {
width: 1px
}
100% {
width: 50px
}
}
<div class="parent"><div></div></div>
<div class="parent"><div style="padding: 0"></div></div>
关于css - 为什么填充有效地创建了最小宽度和最小高度,即使将 box-sizing 设置为 border-box,以及如何处理它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51904276/
有没有办法像 super 速记样式一样在 CSS 中组合 border-top,border-right,border-left,border-bottom。 例如: border: (1px sol
这个问题在这里已经有了答案: Combining border-top,border-right,border-left,border-bottom in CSS (4 个答案) 关闭 3 年前。
所以,我是那些以始终使用最新版本的浏览器而自豪的人之一(当然 Internet Explorer 除外 - 我说的不是那个浏览器)。 我遇到了 this awesome CSS3 website详细介
border-top-color 是 #9b9c9d 而 border-bottom-color 是 #f6f9fc .渐变旨在在border-left 和border-right 上将顶部颜色过渡到
我将开始开发一个新网站,并准备处理浏览器用于计算元素宽度和高度的不同方法 (box model stuff)。不知何故,我想到了:如果我只是将 box-sizing 应用于网站中的所有元素会怎么样?
这是 fiddle :http://jsfiddle.net/3Ys2d/ CSS div{ border: solid 3px blue; border-left-color: re
这个接缝很容易,但我还没有找到任何方法来做到这一点。我有 3 个 div(但解决方案必须适用于 n 个 div),如下图所示: |分区 1 ||分区 2 ||第 3 部分 | 例如: 我想要这样的普通
由于视网膜显示器具有如此高的像素密度,因此在这些显示器上 1 像素的边框看起来非常大。正如 Brad Birdsall 所建议的,CSS box-shadow属性可用于创建“0,5 px”边框,在
我可以这样写边框的样式: border: 2px solid #DDDDDD; 或者像这样: -moz-border-bottom-colors: none; -moz-border-left-col
当在已经有 1px 边框的 div 中覆盖 border-bottom 的大小时,Firefox 和 Chrome 呈现 border-left 和 border-right 不正确: HTML C
我是CSS3新手,最近在学习border-image属性,在看W3C文档的时候: http://dev.w3.org/csswg/css-backgrounds/#border-image-width
我正在尝试在使用 border-radius 属性的 div 上使用 border 属性。 这是我的 CSS: #page { border: 1px solid #beb2b2; w
我只想在已经具有顶部和底部边框(1px 纯灰色)的 div 上添加一个左边框(5px 纯蓝色)。我希望 border-left 位于 border-top 和 border-bottom 之上,但浏览
我有一个使用 border-radius 的带有圆 Angular 的流体宽度 div,以及 div 一侧的大边框,颜色不同。 当浏览器窗口足够小时,所有边框都会正常运行。但是,当我放大窗口大小时,我
导致“错误”的 Css: div { width: 100px; height: 100px; background-color: transparent; box-s
Border-bottom长度小于border-right怎么办? img { border-bottom: 5px solid #02a8d8; border-right:1px s
我是一名优秀的程序员,十分优秀!