在html中,为什么插入图片后,就只显示文字,而把文本框覆盖了,该怎么让文本框显示?

在html中,为什么插入图片后,就只显示文字,而把文本框覆盖了,该怎么让文本框显示?,第1张

方法1:将图片设为背景图 background:url(xx.jpg)<div style="background:url(xxx.jpg)"><input type="text"></div>方法2:使用定位 并使用z-index:5(整数可以任意填写 数值越大越有限显示)

<!doctype html><html><head>

<meta charset="utf-8"><title>今日新鲜事_百度搜索</title> <style type="text/css">

*{ margin: 0 padding: 0 }

.w {width: 1200pxmargin:0 auto}

.div01{ height: 80px width: 100% background: hsla(0,0%,100%,1.00) padding-bottom: 20px }

.logo img {width: 150pxmargin-right:30pxposition: relative top: 13px}

.text01{ height: 40px width:600px font-size: 20px }

.button01{ height: 44px width: 125px background:blue color: alicebluefont-size: 20px }

.div02{width: 100%background: #f5f5f5 } ul li{ list-style: none float: left }

.div02 ul{ overflow: hidden background: hsla(0,0%,97%,1.00)}

.div02 li{ padding: 0 20px font-size: 20px line-height: 50px color:#555 display: blocktransition: all 1s }

.div02 li:hover {background: #1bb3cc}

.p1{ color:hsla(0,0%,40%,1.00) font-size: 13pxmargin-top: 15px }

.p2 {margin-bottom: 30px}

.div03{ border:solid 1px #ddd margin-top: 10pxpadding: 10px position: relative}

.div03 .tmpimg {margin-right:20px}

.div03 img {width: 140pxheight: 140px}

.div03>div {display: inline-blockheight: 140px float: left}

.div03:after { clear: both display: block height: 0px content: "."}

</style></head>

<body>

<div class="div01">

<div class="logo w">

<form action="#" method="get"> <img src="../img/baidu_jgylogo.gif">

<input class="text01" type="text" value="今日新鲜事"><input class="button01" type="button" value="百度一下">

</form>

</div>

</div>

<div class="div02">

<ul class="w">

<a href="#"><li><strong>网页</strong></li></a>

<a href="#"><li>资讯</li></a>

<a href="#"><li>视频</li></a>

<a href="#"><li>图片</li></a>

<a href="#"><li>知道</li></a>

<a href="#"><li>文库</li></a>

<a href="#"><li>贴吧</li></a>

<a href="#"><li>采购</li></a>

<a href="#"><li>地图</li></a>

<a href="#"><li>更多»</li></a>

</ul>

</div>

<p class="p1 w">百度为您找到相关结果约10,500,000个</p>

<div class="div03 w">

<div class="tmpimg">

<img src="../img/long.png" class="img1">

</div>

<div>

<p class="p2">2019年6月29日(星期六)</p> <h2 class="h1">龙船节</h2> <p class="p3">农历五月廿四至廿七是龙船节。苗族的端午节有龙舟竞渡的习俗,居住黔东南的台江、凯里、剑河、施秉、镇远...<a href="https://baike.baidu.com/item/%E9%BE%99%E8%88%B9%E8%8A%82?from=kg_qa">查看更多</a>

</p>

</div>

</div>

</body></html>

可以把图片作为文字那个块标签的背景图片或者你把图片和文字都放在一个同一个div 里面然后给图片和文字加上定位,然后文字的图层比图片的图层位置高就行了。

第一种

<style>

.div{width: 200pxheight: 200pxbackground: url("图片路径") no-repeat}

</style>

<div class="div">

<p>你的文字内容</p>

</div>

第二种

<style>

.div{width: 200pxheight: 200pxposition: relativez-index: 0}

.div img{position: absolutetop: 0left: 0width: 100pxheight: 100px}

.div p{position: absolutetop: 0left: 0z-index: 10}

</style>

<div class="div">

<img src="图片路径" alt="#">

<p>你的文字内容</p>

</div>

CSS怎么将一个元素重叠到图片上显示,假如我有一张图片,图片上面显示半透明的横条,横条上面有文字,效果如图:

<style>

.nav{backgrouan:url("../tupian.jpg")width:100pxheight:300px}

.nav ui li {width:100pxheight:30pxfilter:alpha(Opacity=80)-moz-opacity:0.5opacity: 0.5z-index:100background-color:#ffffffmargin-top:270px}

</style>

<div clas="nav">

<ul>

<li><a href="#">青山绿水</a></li>

</ul>

</div>

用CSS滤镜 纯手打


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7228104.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存