随便写几种。
------------------------------
CSS部分:
.text{background-imageurl(pic.jpg)
width: xx px /*你自己定义的宽*/
height: xx px /*你自己定义的高*/
overflow:hidden/*超出部分隐藏*/}
.text span{
margin-top:xx px/*离上边距离*/
margin-left:xx px/*离左边距离*/
}
html部分:
<div class="text"><span>字</span></div>
------------------------------
CSS部分:
.text{background-imageurl(pic.jpg)
width: xx px /*你自己定义的宽*/
height: xx px /*你自己定义的高*/
position:relative/*相对定位*/}
.text span{
position:absolute/*绝对定位*/
top:xx px/*离上边距离*/
left:xx px/*离左边距离*/
}
html部分:
<div class="text"><span>字</span></div>
--------------------------------------
CSS部分:
.text{background-imageurl(pic.jpg)
width: xx px /*注意,这里是你自己定义的宽减去padding-left的值*/
height: xx px /*注意,这里是你你自己定义的高减去padding-top的值*/
padding-top:xx px/*离上边距离*/
padding-left:xx px/*离左边距离*/
}
html部分:
<div class="text">字</div>
lz自己选吧。
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style type="text/css">
* {
margin: 0
padding: 0
}
.demo {
margin: 0 0 0 100px
}
.img {
width: 200px
height: 200px
border: 1px solid #DCDCDC
padding: 5px
box-sizing: border-box
}
.img img {
width: 100%
height: 100%
}
.msg {
width: 200px
text-align: center
box-sizing: border-box
word-break: keep-all
white-space: nowrap
overflow: hidden
text-overflow: ellipsis
position: relative
border: 1px solid #000000
/*left: -30px你是不是布局出现了问题,如果你非要左移的话,去掉注释*/
}
</style>
<body>
<div class="demo">
<div class="img">
<img src="http://pic1.win4000.com/wallpaper/6/578855acae491.jpg" />
</div>
<div class="msg">
自驾游(多余的文字)<br> 会员价:
<strong style="color: red">9999元</strong>
</div>
</div>
</body>
</html>
line-height。1、通过设置line-height例如line-height:120%。
2、可以font-size:140%,设置字体的大小。
3、letter-spacing:10px,字与字之间的间距是10px距离。以上是css在图片右侧加文字变化宽度,图片会移动的教程。