一、水平居中
1.margin:0 auto在绝对定位中就失效了
2.如何让绝对定位的元素水平居中?
只需要设置绝对定位元素的left:50%;然后再设置绝对定位元素的margin-left:-元素宽的一半;
这样就可以完成水平居中了
div{ width:50px;/*如果数值为100%,就代表这个div的宽度就是浏览汉文帝的妃子器的整个宽度*/ height:50px; background-color: 贵宾狗狗red; position:absolute; left:50%;/*使用百分比意味着这个绝对定位的块左边距离浏览器一半的距离*/ } .......省略代码...... <body><div></div></body>
二、团购界面
注意点:这里的标志以及电脑配置,都是通过设置背景图片和绝对定位、相对定位来进行配置上的;这里面使用了span这个标签,由于已经脱离了标准流,因此不需要在设置为display:inline-block;了
<!doctype html><html lang="en"><head> <meta chart="utf-8"> <title>d155_grouppurcha</title> <style> *{ margin:0px; padding:0px; } div{ width: 500px; height: 550px; border:1px black solid; margin:0 auto; margin-top:100px; position:relative;/*这里想要利用子绝父相来进行排版图片的商标和配置的信息*/ } div img{ width: 500px; height: 500px; } div .brand{ width: 111px; height: 29px; background: url("image/laptop_label.jpg") no-repeat -21px -12px; position:absolute; left: 20px; top:0px; } div .configuration{ width: 435px; height: 40px; background:url("image/laptop_label.jpg") no-repeat -78px -515px; 二次函数求根公式 position:absolute; left:20px; 竖子不足与谋句式 top:505px; }</style></head><body><div> <img src="image/laptop.jpg" alt=""> <span class = "brand"></span> <span class = "configuration"></span></div></body></html>
三、源码:
d154_centerhorizontally.html
d155_grouppurcha.html
地址:
https://github.com/ruigege66/html_learning/blob/master/d154_centerhorizontally.html
https://github.com/ruigege66/html_learning/blob/master/d155_grouppurcha.html
2.csdn:https://blog.csdn.net/weixin_44630050
3.博客园:https://www.cnblogs.com/ruigege0000/
4.欢迎关注微信公众号:活动计划傅里叶变换,个人账号,仅用于技术交流,后台回复“礼包”获取java大数据学习视频礼包
本文发布于:2023-04-07 08:01:56,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/9eaae8243eb55d9c6f63ef4ad8d5a6a4.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:HTML连载60.doc
本文 PDF 下载地址:HTML连载60.pdf
留言与评论(共有 0 条评论) |