【发布时间】:2016-03-01 20:02:30
【问题描述】:
这个问题让我发疯了——我只能找到部分答案,这些答案在我的整个代码中都不起作用。我正在尝试将混合“点赞按钮”(来自外部站点的 <script> 片段)和图像(我设置为 <a>s 的内联列表居中,其中“点赞按钮”不可用)
要求是: 1. 一切都需要与父 div 的顶部边缘对齐——这就是为什么我使用 ul、li、display:table 和 display:table-cell 来对齐顶部(而不仅仅是 inline-block) 2.一切都需要在同一条水平线上,这就是为什么它们需要浮动(在没有inline-block的情况下) 3.一切都需要居中(这是我做不到的一点!)
这是我第一次使用论坛,我不是一个真正的网页设计师,所以请温柔!我附上了我认为相关且有用的代码。
#contact {
position: relative;
top: 1em;
margin-left: 0;
width: 100%;
display: inline-block;
}
#contactinfo {
margin-right: 0;
color: #00CCFF;
text-decoration: none;
text-align: center;
width: 100%;
padding-bottom: 1em;
}
#share {
position: relative;
text-align: center;
min-height: 1em;
display: inline;
vertical-align: top;
}
ul.button {
display: table;
min-height: 2em;
list-style: none;
list-style-position: inside;
padding-left: 0.5em;
margin-left: 0em;
text-align: center;
float: right;
}
ul.button li {
display: table-row;
vertical-align: top;
text-align: center;
height: 2em;
padding: 0.5em;
}
img.sharebutton {
max-width: 50px;
max-height: 35px;
padding-bottom: 1em;
}
<div id="contact">
<div id="contactinfo">
<h2>
email <a href="mailto:info@lysamorrison.com"> info@lysamorrison.com</a><br>
call 0796 99 777 68
</h2>
</div>
<div id="share">
<div class="sharebuttons">
<ul class="button">
<li>
<a href="http://www.eventbrite.com/o/lma-training-amp-consultancy-8057832740" target="_blank">
<img src="eventbrite.png" class="sharebutton" />
</a>
</li>
</ul>
</div>
<div class="sharebuttons">
<ul class="button">
<li>
<a href="http://www.meetup.com/LMA-Personal-Professional-Development-Whitley-Bay-Meetup/#upcoming" target="_blank">
<img src="meetup.png" class="sharebutton" />
</a>
</li>
</ul>
</div>
<div class="sharebuttons">
<ul class="button">
<li>
<script src="//platform.linkedin.com/in.js" type="text/javascript">
lang: en_US
</script>
<script type="IN/FollowCompany" data-id="1586406"></script>
</li>
</ul>
</div>
<div class="sharebuttons">
<ul class="button">
<li><a href="https://twitter.com/LMAtrainconsult" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @LMAtrainconsult</a>
<script>
! function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + '://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'twitter-wjs');
</script>
</li>
</ul>
</div>
<div class="sharebuttons">
<ul class="button">
<li>
<div class="fb-follow" data-href="https://www.facebook.com/lmatrainingandconsultancy" data-height="35" data-layout="button" data-show-faces="true"></div>
</li>
</ul>
</div>
</div>
<!--End of share div-->
</div>
【问题讨论】:
-
一张应该是什么样子的图片会很有用。目前还不清楚您要做什么。
-
您好 Paulie - 拍了一些屏幕截图给您看,但不知道如何附加图片。基本上,我有一个相当流畅的 CSS 布局,可以根据设备、浏览器宽度等切换到另一个样式表。在全宽时,按钮正确对齐到右侧;当宽度减小到某个值以下时。像素,我希望它们居中 - 但不能让它们都对齐顶部和居中,使用浮动
-
您必须在图片托管网站上拥有图片并提供链接。
标签: css vertical-alignment floating display