当前位置: 首页 > Web前端 > CSS

css的居中效果,li鼠标悬停背景色从上到下变化,选择器的分类和使用

时间:2023-03-30 19:13:03 CSS

一个css居中效果(一)垂直居中divli{height:30px;行高:30px;}(2)水平居中divli{text-align:center;}(3)块级元素insidediv水平居中divp{margin:0auto;宽度:50%;}(4)块级元素在div垂直居中divp{height:300px;行高:300px;}2.limousehoverbackgroundcolorfromtopNextchangeullia{text-decoration:none;颜色:#dddddd;显示:块;背景:线性渐变(白色50%,#37373550%);背景大小:100%200%;背景位置:0100%;}ullia:hover{背景位置:00%;颜色:#000;过渡:背景.3s缓和;}3.选择器的分类和使用(1)核心选择器标签classid和p.one#firstorp,.one,#first(2)hierarchicaldescendantparentsonschildparent>sonsnextsibling.one+*allsubsequentsiblings。one~*(3)attributeselector(filter)withbasicSelectortofilterselector[name]input[name=username]选择有name属性的元素和name的值isvalinput[name*=use]选择name属性的元素,name的值包含user的元素input[name^=u]选择name属性name值以val开头的元素innput[name$=e]选择name属性name值以e结尾的元素suinput[name~=username]选择具有name属性且name其中一个值为username的元素(4)伪类选择器配合基本选择器进行过滤1)子元素:first-child:last-child:nth-child():first-of-type:last-of-type:nth-of-type()2)State:hover:active:focus(5)伪元素选择器::after常用于清除浮动元素持有上父母。