我创建了三个社交图标并排坐在一排(请参阅我的工作 JSFiddle - here)。
然而,当我将它们放在我的 Wordpress 博客上时,它们不是并排坐在一起,而是彼此叠放在一起,请参阅 - https://www.moneynest.co.uk/testing-social-icons/ .
如何让我的 Wordpress 版本模仿我的 JSFiddle 版本?
HTML
<div data-sumome-share="Facebook" data-sumome-share-text="Great article by the Money Nest team." class="social-icons" id="facebook_icon"><img src="https://www.moneynest.co.uk/wp-content/uploads/2017/01/facebook-white.png" height="20px" class="social-image-align" >share<span data-sumome-share-count="share"></span></div><!--
--><div data-sumome-share="Twitter" data-sumome-share-text="Great article, check it out..." class="social-icons" id="twitter_icon"><img src="https://www.moneynest.co.uk/wp-content/uploads/2017/01/twitter-white.png" height="20px" class="social-image-align">share<span data-sumome-share-count="share"></span></div><!--
--><div data-sumome-share="Linkedin" data-sumome-share-text="Great article, check it out..." class="social-icons" id="linkedin_icon"><img src="https://www.moneynest.co.uk/wp-content/uploads/2017/01/linkedin-white.png" height="20px" class="social-image-align">share<span data-sumome-share-count="share"></span></div>
CSS
social-image-align {
position: relative;
top: -1px;
height: 20px;
margin-right: 8px;
}
#facebook_icon {
background-color: #3B5997;
}
#facebook_icon:hover {
background-color: #4264a9;
}
#twitter_icon {
background-color: #1bb2e9;
}
#twitter_icon:hover {
background-color: #32baeb;
}
#linkedin_icon {
background-color: #008cd0;
}
#linkedin_icon:hover {
background-color: #007bb6;
}
.social-icons {
padding: 8px 5px;
text-align: center;
width: 30%;
display: inline-block;
color: white;
text-transform: uppercase;
}
最佳答案
WordPress 似乎在您的 <div>
之间添加了一些段落标签的
如果您无法删除它们,请设置它们的 display
至 none
像这样。
.entry-content p{
display: none;
}
.social-icons {
padding: 8px 5px;
text-align: center;
width: 30%;
display: inline-block;
text-transform: uppercase;
}
<div class="entry-content">
<div data-sumome-share="Facebook" data-sumome-share-text="Great article by the Money Nest team." class="social-icons" id="facebook_icon"><img src="https://www.moneynest.co.uk/wp-content/uploads/2017/01/facebook-white.png" height="20px" class="social-image-align" >share<span data-sumome-share-count="share"></span></div><p><!--
--></p><div data-sumome-share="Twitter" data-sumome-share-text="Great article, check it out..." class="social-icons" id="twitter_icon"><img src="https://www.moneynest.co.uk/wp-content/uploads/2017/01/twitter-white.png" height="20px" class="social-image-align">share<span data-sumome-share-count="share"></span></div><p><!--
--></p><div data-sumome-share="Linkedin" data-sumome-share-text="Great article, check it out..." class="social-icons" id="linkedin_icon"><img src="https://www.moneynest.co.uk/wp-content/uploads/2017/01/linkedin-white.png" height="20px" class="social-image-align">share<span data-sumome-share-count="share"></span></div>
</div>
关于html - 忽略内联 block 的社交图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41811701/