@15013890200
2018-10-12T18:44:04.000000Z
字数 4265
阅读 470
css
前面一节补充了css一些薄弱的知识点。今天集中实践了不少。感觉收获还是蛮多的(平时对css忽略蛮多的,只写了一些基本样式)。
本次主要实践了 display的sticky属性、伪类/伪节点、文本处理、图片处理
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>usefulCss</title>
<style type="text/css">
.div_container{}
.div_container div{height: 200px;border: 1px solid #ddd;margin-bottom: 20px;text-align: center;align-items: center;display: flex;justify-content: center;}
.div_container div:nth-child(2){background-color: #ddd;position: sticky;top: 0;width: 100%;z-index: 100;}
.div_container div:nth-child(2)+div{font-size: 20px;font-weight: bold;color: rgba(255,0,0,0.5);cursor: pointer;}
.div_container div:nth-child(2)~div{border-radius: 5px;transition: box-shadow 0.3s;}
.div_container div:nth-child(2)~div:hover{box-shadow: 0 0 15px 1px #ddd,0 0 8px 0 rgba(255,0,0,0.3) ;margin-top: -1px;}
.div_container div:nth-child(4){transform: scale(0.5,0.5);}
.div_container div:nth-child(5){transform: rotate(3deg);}
.div_container div:nth-child(6){transform: translate(50%,0);}
.div_container div:nth-child(7){transform: skew(50deg,0deg);}
.a{text-decoration: none;}
.a:link{font-size: 18px;}
.a:hover{text-decoration:underline;}
.a:visited{color: #bbb;cursor: not-allowed!important;}
.a:active{color: #3896fe;}
.div_checkbox{margin: 20px;user-select: none;}
.div_checkbox label{cursor: pointer;color: #000;}
.div_checkbox input{cursor: pointer;}
.div_checkbox input:checked+span{color: #3896f8;transition: color 0.3s;}
.div_checkbox input:disabled~span{color: #bbb;cursor: not-allowed;}
.div_radio{margin: 20px;user-select: none;}
.div_radio span{position: relative;top: -2px;cursor: pointer;}
.div_radio input{cursor: pointer;}
.div_radio input:checked+span{color: red;}
.div_words>p{margin: 20px;width: 200px;text-transform: capitalize;letter-spacing: 0;word-spacing: 2px;}
.div_words p:nth-child(2):first-line{color: red;}
.div_words p:nth-child(2){text-indent: 32px;}
.div_words p:nth-child(1):first-letter{font-size: 30px;font-weight: bold;float: left;}
/** 多行文本省略 **/
.div_words2{margin: 20px;width: 200px;display: -webkit-box;-webkit-box-orient:vertical;text-overflow: ellipsis;overflow: hidden;-webkit-line-clamp:3;}
.div_imgs img{width: 200px;height: 100px;margin: 10px;transition: filter 0.1s;}
.div_imgs img:nth-child(1){filter: blur(5px);}
.div_imgs img:nth-child(2){filter: grayscale(100%);}
.div_imgs img:nth-child(3){filter: opacity(50%);}
.div_imgs img:nth-child(4){filter: invert(100%);}
.div_imgs img:nth-child(5){filter: saturate(7);}
.div_imgs img:hover{filter: none;}
</style>
</head>
<body>
<div class="div_container">
</div>
<a href="#b" class="a">bbb</a>
<div class="div_checkbox">
<label><input type="checkbox" name="friuts" value="apple"><span>apple</span></label>
<label><input type="checkbox" name="friuts" value="orange"><span>orange</span></label>
<label><input type="checkbox" name="friuts" value="banana" disabled><span>banana</span></label>
</div>
<div class="div_radio">
<label><input type="radio" name="animals" value="dog"><span>dog</span></label>
<label><input type="radio" name="animals" value="pig"><span>pig</span></label>
<label><input type="radio" name="animals" value="cat"><span>cat</span></label>
</div>
<div class="div_words">
<p>端请求携带必要设备和广告位等信息,接口根据广告位id查找该广告位正在投放的广告信息,再根据条件过滤,选取最符合条件的广告信息。然后判断该广告是否来源于dsp,如果是,则向dsp方请求最新广告素材信息;如果不是,则按照原有逻辑处理。</p>
<p>my name is hhhhh eujhtiuerht heg iewjht</p>
</div>
<div class="div_words2">
端请求携带必要设备和广告位等信息,接口根据广告位id查找该广告位正在投放的广告信息,再根据条件过滤,选取最符合条件的广告信息。然后判断该广告是否来源于dsp,如果是,则向dsp方请求最新广告素材信息;如果不是,则按照原有逻辑处理。
</div>
<div class="div_imgs">
<img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
<img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
<img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
<img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
<img src="http://pic4.iqiyipic.com/image/20170830/c9/9d/a_100045837_m_601_m1_480_270.jpg">
</div>
<script type="text/javascript">
var container = document.querySelector('.div_container');
function createItems(n){
var html = '';
for(var i = 0; i < n; i++){
html += '<div>'+(i+1)+'</div>';
}
container.innerHTML = html;
}
createItems(10);
container.addEventListener('click',getClick,true)
function getClick(e){
var ele = e.target;
if(ele.children.length){
console.log('i click the parent')
}
else{
console.log('i click the child'+ele.innerText)
}
if(ele.innerText == 2){
container.removeEventListener(container,getClick);
}
}
</script>
</body>
</html>