html - CSS 边框底线内边距

标签 html css padding

我正在尝试向 div 的边框底线添加左填充。我怎样才能实现这个目标?

This is what i tried

当我向左添加填充时,文本和边框底线都会移动。

<div class='ot'>
Black border bottom should start from 30px left    <div>

.ot{
   width:100%;
   background-color:yellow;
    border-bottom: solid;       
}

最佳答案

你可以用一些伪内容来捏造它。

http://jsfiddle.net/E7fFL/3/

div {
   width:100%;
   background-color:yellow;
   border-bottom: solid 2px;
   position: relative;
}
div:after {
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 30px;
    height: 2px;
    content: '.';
    background: yellow;
    text-indent: -999px;
}

如果 heightbottom 属性分别与边框宽度等效和相反,则此方法将起作用。

关于html - CSS 边框底线内边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24542013/

相关文章:

javascript - chessboardjs 如何设置黑先走?

javascript - 如何检查单选按钮是否被选中,然后检查下一个单选按钮并显示不同的内容?

html - IE 8 和填充问题

c++ - 在 C++ 中填充和分配 std::string

java - 如何在 java 中用零填充字符串?

javascript - jquery 按名称查找元素(名称有点)显示语法错误,无法识别的表达式 :

html - 调整浏览器屏幕大小时如何使图像大小固定html

javascript - 为什么我的图像被裁剪了?

html - 有没有办法在同一列中设置所有 td 的宽度,而无需为每个 td 手动设置?

css - 单击时更改的带有 css 的动画