如何设置html里面图片和文字的位置
1.首先是图片
<style type="text/css">
body{
background-image:url("src/注册成功最终定稿版.png");//存放图片的路径
background-attachment:fixed;
background-repeat:no-repeat;
background-position:50% 15%;//确定图片在网页的位置
}
</style>
解释一下, background-position:50% 15%;//确定图片在网页的位置 里面不一定要是%也可以是比如 background-position:300px 100px;(数字我随便取的).*
我觉得%可以理解为相对路径,px可以理解为绝对路径,一般我建议取%,因为,比如我在eclipse里面调试如果用px来确定图片位置,确定好了。再用intellj调试,图片的位置就变了,因为px是明确了位置的,不如%自己适应大小。
2.文字的位置(共3行设置3行文字的规格和距离)
<div style="left: 47%; position: absolute; top:23%;font-weight:bold;font-size:19px"> 恭喜您注册成功!</div>
<div style="left: 50%; position: absolute; top:27%; color: blue;font-weight:bold" id="show"></div>
<div style="left: 40%; position: absolute; top:31%;font-size:18px"> 秒钟之后,自动跳转到网站主页,如果没有请手动点击跳转</div>
解释一下,left和top确定图片位置,px和%均可
font-weight确定字是粗体,细体,斜体之类的
font-size是确定文字大小
color确定文字颜色
效果图片:(注册乌托邦的那个是个图片,点击跳转是我自己写的一个超链接)
更多推荐
设置html里面图片和文字的位置
发布评论