html - 段落的一侧边框

标签 html css

我正在尝试使用 :before class 显示段落的左边框。

但输出似乎与我想要实现的有点不同。

代码:

p.left-border::before {
    border-left: 3px solid #9e9464;
    content:"";
    padding: 0 20px 0 0;
    vertical-align: middle;
}
p {
    line-height:30px;
}
 <h4>Our Unique Approach</h4>

<p class="left-border">Aspire to Acheive is unlike anything you’ve ever experienced. The Fellowship brings together some of the world’s most creative and motivated young people, and helps them bring their most ambitious projects to life. Thiel Fellows are given a grant of $100,000 to focus on their work, their research, and their self-education while outside of university.</p>

这里是 demo 的链接到目前为止我所做的一切。

这是我想要实现的截图:

Screen shot of a paragraph of text with a green border to the left that goes down 3 lines but not the entire length of the paragraph.

最佳答案

也许是这样?

p {
    line-height:30px;
    padding-left: 20px;
    position: relative;
}
p.left-border::before {    
    content:"";
    position: absolute; top: 10px; left: 0;    
    vertical-align: middle;
    height: 60%;
    width: 5px;
    background: #9e9464;
}
<h4>Our Unique Approach</h4>

<p class="left-border">Aspire to Acheive is unlike anything you’ve ever experienced. The Fellowship brings together some of the world’s most creative and motivated young people, and helps them bring their most ambitious projects to life. Thiel Fellows are given a grant of $100,000 to focus on their work, their research, and their self-education while outside of university.</p>

关于html - 段落的一侧边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31212579/

相关文章:

JavaScript FancyTree : is it possible to distinguish between the selection of a node and the action of expanding it.

html - 如何在不使用表格的情况下将 4 Div 放置在 2x2 Passion 中?

javascript - 纸.js |从 paperscript 中调用 document.body.style.opacity

jquery - 在 div 中的所有输入元素之后动态添加一个 ul

javascript - 收到 A-,其中 X 应该是关闭窗口

html - 如何仅在悬停时显示滚动条? (支持手机)

javascript - 'onbeforeunload' 的自定义弹出窗口

html - 掩蔽 - 仅在特定 div 顶部显示 div?

html - 尝试将多个 div 标签居中并将它们保持在同一行

html - 为什么我不能将所有 4 个元素都放在同一行中?