如何调整<a> and <p></p></a>之间的空间

时间:2015-01-01 14:13:59

标签: css text space

我试图了解调整<a>元素和<p>元素之间空间的最佳方法。

以下是我为此制作的CodePen:http://codepen.io/theclarkofben/pen/jEVWgz

我特意只调整红色和蓝色文本之间的空间。我不想在蓝色段落文本之后或红色超链接文本之前调整空格。

到目前为止,我已经使用了line-height - 但是在蓝色之后调整了空间,所以不合适。

我也玩-webkit-margin-before -webkit-margin-after,但至关重要的是我正在寻找跨浏览器兼容的内容。

感谢您的时间和帮助。

1 个答案:

答案 0 :(得分:1)

margin-top: 0;margin-bottom:0;padding-top:0; padding-bottom:0;添加到选择器a,p

您可以通过调整这些值来调整空间。

&#13;
&#13;
a {
  color:red;
  text-decoration:none;
}
p {
  color:blue;
  
}
a, p{
  padding-top:0;   /* Here is the code I added */
  padding-bottom:0;
  margin-top: 0;
  margin-bottom:0;
}
&#13;
<h3>Blog Articles</h3>
        <a href="http://blog.hubspot.com/blog/tabid/6307/bid/6126/The-Ultimate-Glossary-120-Social-Media-Marketing-Terms-Explained.aspx">The Ultimate Social Media Glossary</a>
        <p>Found this and had to share</p>
        <h4>Influencer Outreach And Management - 5 Easy Tips</h4>
        <ul>
            <li>Looking for influencers shouldn’t be hard - find the ones that like you already</li>
            <li>Communicate openly, honestly, and frequently with your influencers</li>
            <li>Know their worth and treat them with respect</li>
            <li>Give some creative freedom - people believe people, not advertising</li>
            <li>Finally and very important - don’t leave them hanging. If you run a campaign with influencers, make sure you keep in touch afterwards and nurture the relationship.</li>
        </ul>
&#13;
&#13;
&#13;