练习时用到的一些tip总结


1.网页布局——两列自适应布局

左边浮动 float :left; (固定大小
右边不浮动,设置overflow:hidden; (自适应)

代码如下(示例):

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .parent{
            width: auto;
            height: auto;
            border: 1px solid pink;
        }
        .left{
            width: 500px;
            height: 100px;
            background-color: palegoldenrod;
            float: left;
            margin-right: 10px;
        }
        .right{
            width: auto;
            height: 100px;
            overflow: hidden;
        }
    </style>
</head>
<body>
<div class="parent">
    <div class="left">我是内容</div>
    <div class="right">我是内容</div>
</div>
</body>
</html>

效果图:
在这里插入图片描述

2.绝对定位居中tip

top:50%;
margin-top: -自身高的一半;

3.按钮

页面会常用到左右滑动按钮,用<button>来实现

  • border-style: none; 去默认边框样式
  • outline: none; 去点击时默认蓝色边框
  • 设置圆角:例如
    border-radius: 50% 0 0 50%;
    对应顺序为:左上 右上 右下 左下
    呈现效果:
    在这里插入图片描述

4.超出部分省略

  • 单行

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    

在这里插入图片描述

  • 多行

    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;           /*设置几行*/
    -webkit-box-orient: vertical;
    

5.斜边样式

<border>完成

.lazy_price_miaosha:after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    right: 0;
    top: 0;
    border-width: 22px 8px 0 0;
    border-style: solid;
    border-color: transparent #fff transparent transparent;
}

在这里插入图片描述

6.浮动问题

当给两个子块都设置了浮动,且保证宽度可以并排容纳,也可能是样式设计中的优先级出了问题

7.块元素水平垂直居中

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .box{
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            width: 200px;
			height: 200px;
			border: 1px solid pink;
			margin: auto;
			}
	</style>
</head>
<body>
	<div class="box"></div>
</body>
</html>

7.字母大写

text-transform: uppercase;

8.两元素顶部对齐

分别给两行内块元素设置:vertical-align: top;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

致可乐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值