4 html css image asp.net-mvc-2
我试图将图片定位得稍微低一些,以便图像的中心与标题标签的垂直中心对齐。
这是 HTML 和 CSS。谢谢您的帮助!

#articlesummary
{
border: 2px solid red;
width: 750px;
}
#articlesummary h3
{
border: 2px solid red;
display:inline;
color: #4292C6;
font-family: Verdana;
}
#articlesummary img
{
width:30px;
border: 1px solid red;
margin-top: 5px;
}
.submissionowner
{
color: Gray;
}
<% foreach (var article in Model) { %>
<div id="articlesummary">
<h3><%: article.Title %></h3>
<sub class="submissionowner">Submmited by: <%: article.SiteUser.Login %></sub>
<img src="../../Content/anonymous.png" alt="Anonymous user." />
<p><%: article.Body %></p>
<sub>Views:<%: article.TotalViews %> | Rating: <%: article.TotalRating %></sub>
</div>
<% } %>
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助!
尝试垂直对齐:中间你的img...像这样:http ://www.w3schools.com/css/pr_pos_vertical-align.asp
抱歉,发布了错误的链接/属性
你的 img 类将如下所示:
#articlesummary img
{
width:30px;
border: 1px solid red;
margin-top: 5px;
vertical-align: middle;
}
Run Code Online (Sandbox Code Playgroud)