css3 - CSS中怎么讓一個(gè)div成為遮罩?
問題描述
也就是說讓一個(gè)p限定在另一個(gè)p的區(qū)域里面(類似于css background-image中大尺寸圖片定義在小尺寸的p中,圖像只顯示其在小尺寸p中的部分---但是這里不用background-image,而是換成一個(gè)p,就不知道怎么實(shí)現(xiàn)了 ╮( ̄  ̄)╭)
比如這個(gè)隨便寫的這個(gè)網(wǎng)頁,想讓 .phone:hover 上移的p只顯示其在手機(jī)屏幕中的部分
問題解答
回答1:你自己看下,先考慮下布局
<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'> <head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><title>關(guān)注ReSur的微信</title><style type='text/css'>body {margin: 0;background-color: #FAFAFA;}.block {position: relative;margin-top: 275px;width: 100%;height: 195px;background: #00C389;}.draw {position: relative;margin: 0 auto;height: 391px;height: 579px;background: url(’http://1992s.com/images/wechat-bg.png’) no-repeat;}.draw_box{margin: 134px 0 0 409px; background:#000; width:219px; height:391px; float:left; overflow:hidden; position:relative;}.phone {position: absolute;top: 137px;left:0;width: 219px;height: 391px;text-align: center;background: white;transition: top 1s;-webkit-transition: top 1s;-moz-transition: top 1s;-o-transition: top 1s;}.phone:hover {top: 0px;}.qrcode {position: relative;top: 87px;margin: 0 auto;width: 165px;height: 165px;background: url(’http://1992s.com/images/wechat.png’) no-repeat;}.text {position: relative;top: 140px;font: 12px 'Lucida Grande','Lucida Sans Unicode',Helvetica,Arial,Verdana,sans-serif,'Microsoft YaHei','微軟雅黑';}</style><link rel='shortcut icon' href='http://www.leifengta.com.cn/favicon.ico' type='image/x-icon' /><script type='text/javascript' src='http://1992s.com/wp-content/themes/portfolio-press-child/js/info.js'></script></head><body><p class='block'> <p class='draw'><p class='draw_box'> <p class='phone'><p class='qrcode'></p><p class='text'> <p>或在“查找公眾號(hào)”<br />中搜索“ReSur”</p></p> </p></p> </p></p></body></html>
相關(guān)文章:
1. boot2docker無法啟動(dòng)2. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””3. docker-compose中volumes的問題4. nignx - docker內(nèi)nginx 80端口被占用5. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.6. java - SSH框架中寫分頁時(shí)service層中不能注入分頁類7. golang - 用IDE看docker源碼時(shí)的小問題8. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?9. javascript - mock.js可以存儲(chǔ)數(shù)據(jù)嗎10. docker api 開發(fā)的端口怎么獲取?

網(wǎng)公網(wǎng)安備