‘壹’ html中怎样在背景图片上同时添加图片和文字
写一个div,背景换成图片,div内打上文字
<div style="width:200px; height:200px; background:url( 图片路径)">
<font>文字内容</font>
</div>
‘贰’ 如何在html图片上加文字
你给一个div 添加背景图,不影响在这个div里面添加文字的,比如
<style>
.class{width: 200px;height: 200px;background: url("图片路径") no-repeat;}
</style>
注释:background: url("图片路径") no-repeat;
repeat: 平铺整个页面,左右与上下
repeat-x: 在x轴上平铺,左右
repeat-y: 在y轴上平铺,上下
no-repeat: 图片不重复
<div class="class">
<p>你的文字内容</p>
</div>
那么在这个div的背景图片就有了,你在里面写文字就可以了,如果你想给文字放到特定位置的话就需要定位了
‘叁’ 通过CSS+DIV怎么将文字写在图片上方
HTML图片和文字是并列显示的。如下:
HTML
<div class="img-group"> <img src="img/snow.png">
<div class="img-tip">我是雪豹</div></div>
CSS
.img-group { position: relative; display: inline-block;
}
.img-tip { position: absolute; bottom: 0; background: #333; color: #fff; opacity: 0.6; display: none;
}
.img-group:hover .img-tip { display: block; width: 100%; text-align: center;
}
‘肆’ 在HTML中,怎么在图片上添加文字
一种方式:直接将这个图用ps处理,还有一种html里面有层级代码,修改代码将字这一层放在图片上面
方法1: ps写在图片上
方法2: 给标签加入图片背景, 在标签里面写字
方法3: 使用img加载图片, 样式设置为固定或绝对定位, 添加样式
z-index:-1;
然后写字
<span>dadasdasdas</span>
<imgsrc="XXXX"style="background:rgb(142,107,249);position:absolute;left:0;top:0;width:100%;height:100%;">
‘伍’ html5怎么在图片上加文字
把图片设置为背景图片,然后加上文字就可以了
<style>
.img1{
width:200px;
height:200px;
background-image:url("img/1.jpg");
}
</style>
<div class="img1">图片加文字</div>
‘陆’ 如何在图片上方添加文字,求html代码
用div+css就可以实现
图片是一层,文字是一层
当两层的位置是一样的时候,就会出现图片上有文字等信息了。
‘柒’ html+css怎么在图片上添加文字
要在图片上显示文字,还要在放大缩小的时候文字不到处乱跑,这个就要用盒模型里面的大盒子套小盒子的方法了。下面举个小例子给你看看。
html大致样子:
<body>
<div id="box1">
<div id="box2">
<img src="https://www..com/img/bd_logo1.png">
</div>
<div id="wenzi">这里是文字</div>
</div>
</body>
css文件:
#box1{
position:relative;
width:500px;
height:500px;
margin:0 auto;
}
#box2{
position:relative;
width:100%;
height:100%;
}
img{
position:relative;
clear:both;
width:100%;
height:100%;
}
#wenzi{
position:relative;
clear:both;
width:100%;
top:-50%;
text-align:center;
color:black;
font-size:2em;
}
效果图片:
用这种方法有个好处,就是做响应布局的时候,或者用户在浏览器上放大缩小的时候,网页整体也跟着放大缩小,不会元素到处乱跑或者某个文字跑出来,这样看起来整体感要强烈一点。
这种做法的不足之处:div盒子有点多,html代码看起来比较臃肿,大盒子套着小盒子。做大页面的时候一个htm看起来眼花缭乱的。但只要做好了注释,还是分得清楚的啦,主要是这样弄看起来页面整齐一点。
‘捌’ html中怎么让文字在图片的上面
1、在div里面书写了一些文字,然后想要在放入一张图片。
‘玖’ HTML怎么在图片上加入文字
使用定位来写的,首先一个大盒子装着图片,
然后一个盒子装着头像和文字,把装着头像和文字
的盒子根据装着图片的盒子进行定位就可以了,
像这样的其实很简单的,要多思考和分析
代码,要注意图片你要自己放图片,和修改图片路径
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>图片上放文字</title>
<style type="text/css">
html,body{
margin:0;
}
.auto-img{
display: block;
width:100%;
}
.box{
width:100%;
margin-top: 50px;
}
.box-cent{
width:50%;
margin:0 auto;
position: relative;
}
.texbox{
position: absolute;
width:50%;
line-height: 80px;
background-color: #0f0;
text-align: center;
top:50%;
left:50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="box">
<div class="box-cent">
<img class="auto-img" src="images/000.jpg"/>
<div class="texbox">我是用来装头像和文字的盒子</div>
</div>
</div>
</body>
</html>