自适应内部元素图{max-width:300px;max-width:min-content;//该关键字将被解析为该容器内最大不可破坏元素的宽度(即固定宽度的最宽字、图片或框元素。margin:auto;}figure>img{max-width:inherit;
Sometext[...]
MoreText[...]
精确控制表格列宽table{table-layout:fixed;width:100%;*:请注意,为了使这个技巧起作用,您需要为这些表格元素指定宽度(即使是100%)。此外,为了使text-overflow:ellipsis起作用,我们还需要为其指定宽度柱子。**:如果不指定任何宽度,则每列的宽度会均匀分布;后续表格行不会影响列宽;给cell指定大宽度也会直接生效,不会自动收缩;overflow和text-overflow属性都可以正常生效;如果overflow的值可见,则单元格的内容可能会溢出。只有一个元素时,根据兄弟元素个数设置样式li:only-child{/*...*/}orli:first-child:nth-last-child(1){//括号中的1为参数/**/}当有多个元素时li:first-child:nth-last-child(4)//选中的是第一个正好有四个元素的li:first-child:nth-last-child(4)~li//正好有四个的时候可以用兄弟选择器把四个元素全部选中elements根据兄弟元素个数匹配的元素li:nth-child(n+4)//选择从第4个开始的所有元素li:first-child:nth-last-child(n+4),li:first-child:nth-last-child(n+4)~li{/*...*/}//Allelementswhenthetotalnumberofselectedelementsis4ormoreli:first-child:nth-last-child(-n+4),li:first-child:nth-last-child(-n+4)~li{/*..*/}//只有当元素小于等于4时才选择所有元素li:first-child:nth-last-child(n+2):nth-last-child(-n+6),li:first-child:nth-last-child(n+2):nth-last-child(-n+6)~li{/*...*/}//当元素个数为2-6时,选择所有元素a的全??角背景nd固定宽度的内容.hello{max-width:900px;padding:1emcalc(50%-450px);//替换内部元素的边距:auto;背景:#333;