【问题标题】:want to add image left corner of div想在 div 的左角添加图像
【发布时间】:2011-04-23 15:45:18
【问题描述】:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>

<style type="text/css">
.connection {
cursor:pointer;
display:block;
height:80px;
position:absolute;
width:50px;
}
.ui-widget-content {
color:#FFFFFF;
}


.ui-corner-all {
-moz-border-radius:6px 6px 6px 6px;
}
.ui-widget-content {
background:url("images/ui-bg_inset-soft_25_000000_1x100.png") repeat-x scroll 50% bottom #000000;
border:1px solid #666666;
color:#FFFFFF;
}
.ui-widget {
font-family:Segoe UI,Arial,sans-serif;
font-size:1.1em;
}
.con-text {
 font-size:0.7em;
  margin-top:-0.7em;
  padding:2px;


}
.conimage {
background:url("access-link-card.png") no-repeat scroll 0 0 transparent;
}
.con-icon {
margin:0 auto;
text-align:center;
z-index:100;
 background: url("access-link-card.png") no-repeat;
    padding-left: 34px;
}
</style>
</head>

</head>
<body>

<div class="connection ui-draggable" id="connection-581" style="left: 435px; top: 123px;">    
    <div class="con-icon" id="con_icon-581">   
        <div class="con-text ui-widget ui-widget-content ui-corner-all" id="con-text-581">        Rahul3      
        </div>    
    </div>   
</div>
</body>
</html>

我希望这个图像在 div 上下文或 con-icon 的左角作为徽章, 图片不是全尺寸的,请帮助图像如何以全尺寸显示

问候 拉胡尔

【问题讨论】:

    标签: css image html background


    【解决方案1】:

    将其设置为背景图片并为元素添加内边距,使文本出现在图片的右侧:

    .con-text {
      font-size:0.7em;
      margin-top:-0.7em;
      padding:2px;
      background: url(your_image_url) no-repeat;
      padding-left: something-greater-than-image-width px;
    }
    

    【讨论】:

    • 嗨,我已经更改了代码并进行了有问题的编辑,现在问题是图像不是全尺寸,请帮助图像如何以全尺寸出现
    • widthheight 设置为大于图像大小的div。
    【解决方案2】:

    你可以试试卡萨布兰卡的回答,另一种选择是设置图片的背景位置:

    .con-text {
        background url('yourImage.jpg') no-repeat 5px 2px;
    }
    

    定位背景元素时,两个像素值是水平的,例如(5px)然后是垂直的(2px)。

    使用浏览器的开发工具调整到所需位置。

    【讨论】:

      猜你喜欢
      • 2013-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多