实例首页
自学教程
IT工具箱
源代码
下载代码
上下布局
点击运行 >
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>css position 定位图片文本-居中 实例 - 自学教程(runoops.com)</title> <style> .container { position: relative; } .center { position: absolute; left: 0; top: 50%; width: 100%; text-align: center; font-size: 18px; margin-top: -9px; } img { width: 100%; height: auto; opacity: 0.3; } </style> </head> <body> <h2>图片文本</h2> <p>在图片中间位置添加文本信息:</p> <div class="container"> <img src="//demo.runoops.com/static/img/a1.jpg" alt="Norway" width="1000" height="300"> <div class="center">居中</div> </div> </body> </html>
运行结果: