[HTML+CSS] 笔记总结

笔记:

几种水平垂直双方向居中的方式对比

绝对定位的方式

/* 这种居中方式,只适用于元素的大小确定 */
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;

table-cell的方式

/* table-cell的方式具有一定局限性 */
display: table-cell;
vertical-align: middle;
text-align: center;
transform的方式

/* transform变形平移的方式 */

position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);

flex居中

父元素设置disflex
弹性盒居中
align-items: center;
justify-content: center;

/* 隐藏logo中的文字 */
text-indent: -9999px;

多余显示省略号:

display:block;
white-space: nowrap;
overflow: hidden;
/*
text-overflow 文本溢出
ellipsis显示省略号效果
*/
text-overflow: ellipsis;
posted @ 2022-09-05 10:37  &漠。  阅读(42)  评论(0)    收藏  举报