html - 将图像对齐到容器中文本的右侧

标签 html css stylesheet

我正在尝试对齐我网站上找到的两个图标(facebook 和 google+ 图标)here .这些小圆形图标位于顶部导航栏的正下方。导航栏是类“container_header”的一部分,在文件“stylesheet.css”中定义。

网页“index.php”包含此代码,其中图标应包含在顶部容器中:

<div class ="container_header">
<div class="header_img"><a href="index.php" class="head"><img border="0" src="images/introspect-pictures_logo_header.png" alt="Home" width="185" height="28"></a></div>
<div class="header">
<a href="index.php" class="body">HOME</a>..........<a href="about.php" class="body">ABOUT</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<div id="social">
<a href="https://www.facebook.com" target="_blank"><img border="0" src="images/ic_fb.png" alt="Facebook"></a>
<a href="https://www.google.com" target="_blank"><img border="0" src="images/ic_gp.png" alt="Google+"></a>
</div>
</div>
</div>

在“stylesheet.css”中,图标(在“social”类中)定义了它们的属性(带有“#”):

#social {
float: right;
width: 60px;
text-align: right;
}

#social a {
float: right;
margin: 20px 0 0 5px;
}

#social a img {
width: 24px;
height: 24px;
border: 0;
}

“container_header”类属性在同一文件中定义为:

.container_header{
width:800px;
margin:0 auto 0 auto;
padding:10px;
border:0px solid #000000;
border-radius: 5px;
color: #666666;
}

任何人都可以帮我将它们对齐到导航栏旁边(“关于”旁边),以便它们也包含在容器 width (800px) 中。

非常感谢,

皮特

最佳答案

首先,去除.headerwidth。这就是为什么您的社交图标不在您的菜单项旁边的原因。然后从 #social a 中删除 margin-top

编辑:.header 使用 width:100%; 也可以。

希望对您有所帮助。

关于html - 将图像对齐到容器中文本的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28058510/

相关文章:

c# - 如何在 MVC.NET 中加载前 x 个项目并为用户提供加载更多项目的选项

css - 响应图像在移动设备上未正确对齐

html - 具有相同高度的 float 字段集

asp.net - 样式表对齐问题

html - 如果我不想让我的网站被搜索引擎收录,我该怎么办?

javascript - 不使用 javascript 从输入字段中检索值以进行数据库插入

javascript - 让多个实例只显示被点击的实例

html - CSS - 如何添加第二个渐变使这个按钮半透明?

asp.net-mvc-3 - 如何在 ITextSharp 4 中使用 css 和样式表

html - Apple iphone 导致按钮在网站上被压扁