html - 从 div 左侧开始底部边框 20px
问题描述
<style>
.dt-product-line {
padding-left: 20px;
border-bottom-width: 2px;
border-bottom-style: dashed;
}
</style>
<div class="dt-product-line">This is my text</div>
我希望底线仅从文本出现到 div 的其余部分。这个 css 在整个 div 下划线,而文本缩进 20px。
我怎样才能让边框底线像文本一样从 20px 开始?
解决方案
您可以将文本包装在<span>
标签和样式中,而不是
.dt-product-line {
padding-left: 20px;
}
.underline {
border-bottom-width: 2px;
border-bottom-style: dashed;
}
<div class="dt-product-line"><span class="underline">This is my text</span></div>
推荐阅读
- android - 从深层链接启动时,我可以使用代码退出我的 android 应用程序吗?
- python - 根据特定列对列进行排序 | 蟒蛇 | 熊猫
- python - 为什么在 Python 中选择模块级函数而不是 @staticmethod(根据 Google 样式指南)?
- sql - PostgreSQL 全文搜索在某些情况下不起作用(Django)
- html - 在 Bootstrap 中使用 HTML 元视口标签
- javascript - 语法错误意外令牌} nodejs
- sql-server - 兼容模式允许新命令?
- excel - 在 Excel 列表中标记剩余匹配项
- r - R中按组的时间序列描述性统计
- python - 在 Gtk.Treeview 中设置我自己的拖动图标