asp.net - 如何将文本与旁边的图像对齐?

标签 asp.net css

我正在努力将文本与旁边的图像对齐。我想将带有文本的图像放在 ASP.NET Ajax TabContainer 中(特别是在 TabPanel 中),我希望它适用于这种情况和其他情况。我搜索了很多,但大多数资源都讨论了基于图像高度或宽度的特殊情况。如果我有不止一张不同尺寸的图片怎么办。

那么您能帮我提供一种将文本与任何图像对齐的方法吗?

我的 ASP.NET 代码:

<ajaxToolkit:TabPanel ID="ImagesGallery" runat="server" OnDemandMode="Once" Enabled="true" >
        <HeaderTemplate><img src="images/New/image.png" class="icon" alt=""  /> Images Gallery</HeaderTemplate>
</ajaxToolkit:TabPanel>

我试图让它工作的 CSS 是:

/* For aligning the image (icon) with the text */
.icon
{
    display: block;
    margin-left: auto;
    margin-right: auto 
}

最佳答案

在你的图片上使用vertical-align:middle;
这是一个带有 stackoverflow 图标的示例 http://jsfiddle.net/tDfDP/

希望这有帮助

关于asp.net - 如何将文本与旁边的图像对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11586003/

相关文章:

javascript - 调整图像大小以完美适应可变尺寸的 div

html - 强制绝对位置元素和另一个元素之间的空间

c# - 实体类型 ApplicationUser 不是当前上下文模型的一部分

c# - 如何在 c# asp.net 中制作下载按钮?与查询?

asp.net - 防止百分比字符转换

firefox - 在 Safari 和 Opera 中应用边框图像时,背景图像不显示

css - 如何将图像底部对齐到 h1?

html - 溢出 :scrol doesn't show the scroll

c# - 每个数据行的重复值

html - Ionic Build 在不存在的地方创建 DIV?