我正在尝试将div标签中的图像对齐以放置在最右边。我用谷歌搜索并尝试了一些选项,例如class =“ rounded float-right”和class =“ pull-right”,但img仍位于最左边。任何帮助表示赞赏。谢谢,
<div>
<a>
<div>
<img src="/assets/img/myimage.gif" class="rounded float-right"/>
</div>
</a>
</div>
答案 0 :(得分:0)
由于上下文不多,很难说出您真正想要的是什么,但以下示例又如何呢?
{
string connectionString = "Data Source=###;Initial Catalog=###;Integrated Security=True";
if (!Page.IsPostBack)
{
using (SqlConnection sqlConnection = new SqlConnection(connectionString))
{
sqlConnection.Open();
using (SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(UserID) from Info WHERE UserID like @UserID", sqlConnection))
{
string UserID = HttpContext.Current.Request.LogonUserIdentity.Name.Substring(4);
sqlCommand.Parameters.AddWithValue("@UserID", UserID);
int userCount = (int)sqlCommand.ExecuteScalar();
if (userCount == 0)
{
Server.Transfer("ErrorPage.aspx");
}
SQLCmd = SqlDataSource1.SelectCommand;
GridView1.DataBind();
}
}
}
a {
display: block;
width: 100%;
text-align: right;
}
或者:
<div>
<a>
<div>
<img src="https://cdn.pixabay.com/photo/2014/09/03/20/15/legs-434918_960_720.jpg" class="rounded float-right"/>
</div>
</a>
</div>
a {
display: block;
width: 100%;
position: relative;
}
a img {
position: absolute;
right: 0;
}