正在回答 回答被采纳积分+1
3回答
好帮手慕阿满
2019-02-28 19:27:19
参考一下如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | HTML代码: < div class = "aboutleftbottom" > < p >Praesent dignissim viverra est, sed bibendum ligula congue non. Sed ac nisl et felis gravida commodo? Suspendisse eget ullamcorper ipsum. Suspendisse diam amet.</ p > < a >EXPLORE</ a > </ div > CSS: .aboutleftbottom { border: 1px solid #C5C5C5; padding: 25px 25px; text-align: left; position: absolute; width: 320px; top: 350px; color: black; background-color: rgba(255, 255, 255, 0.4); } .aboutleftbottom p{ margin-bottom:10px; line-height:25px; } .aboutleftbottom a{ background-color:black; padding:10px 15px; color:white; border:2px solid black; margin:8px 0px; display:inline-block; } |
这个需要结合其他代码一起完成作业效果。同学只做参考,另外使用遮罩层完成也可以。祝:学习愉快~
yangyang533
2019-02-27 19:58:54
建议使用遮罩,如果单纯使用元素opacity的属性会导致元素的整体都变得半透明,后果就是像图片上的那样,黑色边框和文字都变成变成了灰色。
我是在文字上方加了一层白色半透明遮罩,配合使用的绝对定位和z-index属性,可以完美的实现效果图里的效果。
参考代码:
html
1 2 3 4 5 6 7 8 9 10 11 | < div class = "aboutTopLeft" > < h2 >A WORD < br >ABOUT US</ h2 > < div class = "description" > < div class = "text" > Present dignissim viverra set,bibendum ligula congue non.Sed ac nislet felis gravida commodo? Suspendisse eget ullamcorper ipsum.Suspendisse diam amet. </ div > < div class = "topLayer" ></ div > <!--description的半透明遮罩--> < a href = "#" >EXPLORER</ a > </ div > </ div > |
css:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | .about .aboutTop .aboutTopLeft{ /*border: 1px solid navy;*/ width : 19.3% ; /*height: 450px;*/ position : absolute ; top : 340px ; left : 22% ; } .about .aboutTop .aboutTopLeft h 2 { /*border: 1px solid purple;*/ font-size : 4em ; font-weight : normal ; margin : 10px ; } .about .aboutTop .aboutTopLeft .description{ width : 100% ; height : 330px ; position : relative ; border : 2px solid rgb ( 157 , 137 , 146 ); } .about .aboutTop .aboutTopLeft .description .text{ position : absolute ; top : 0 ; left : 0 ; z-index : 10 ; margin : 7% ; font-size : 2.2em ; line-height : 35px ; } .about .aboutTop .aboutTopLeft .description .topLayer{ width : 100% ; height : 100% ; position : absolute ; top : 0 ; left : 0 ; z-index : 5 ; background-color : #ffffff ; opacity: 0.5 ; } .about .aboutTop .aboutTopLeft .description a{ display : block ; width : 130px ; height : 60px ; line-height : 60px ; text-align : center ; font-size : 2.3em ; background-color : #000000 ; color : #ffffff ; border : 2px solid #000000 ; position : absolute ; top : 75% ; left : 7% ; z-index : 15 ; } .about .aboutTop .aboutTopLeft a:hover{ background-color : #ffffff ; color : #000000 ; } |
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10204 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧