几个实用css小技巧

一、元素的高度与 window 的高度相同

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>css小技巧</title>
        <link rel="stylesheet" type="text/css" href="test.css">
    </head>
    <body>
        <div class="app">
            <div class="child"></div>
        </div>
    </body>
</html>
*{
    margin: 0;
    padding: 0;
}
.child{
    width: 100%;
    height: 100vh;
    background-image: linear-gradient(180deg,#2af589 0%,#009efd);
}

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

二、 修改 input placeholder 样式

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>css小技巧</title>
        <link rel="stylesheet" type="text/css" href="test.css">
    </head>
    <body>
        <input type="text" class="placehoder-custom" placeholder="Please enter user name to search">
        <input type="text" placeholder="Please enter user name to search ">
    </body>
</html>
*{
    margin: 0;
    padding: 0;
}
input{
    width: 300px;
    height: 30px;
    outline: none;
    display: block;
    margin: 10px;
    border: solid 1px #dee0e9;
    padding: 0 15px;
    border-radius: 15px;
}
.placehoder-custom::-webkit-input-placeholder{
    color: #babbc1;
    font-size: 12px;
}

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

三、使用 caret-color 来修改光标的颜色

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>css小技巧</title>
        <link rel="stylesheet" type="text/css" href="test.css">
    </head>
    <body>
        <input type="text" class="caret-color" />
    </body>
</html>
*{
    margin: 0;
    padding: 0;
}
body {
    display: flex;
    justify-content: center;
  }
  
.caret-color {
    width: 300px;
    padding: 10px;
    margin-top: 20px;
    border-radius: 10px;
    border: solid 1px #ffd476;
    box-sizing: border-box;
    background-color: transparent;
    outline: none;
    color: #ffd476;
    font-size: 14px;
    /* 改变光标颜色 */
    caret-color: #ffd476;
}
  
/* 改变输入框内输入样式 */
.caret-color::-webkit-input-placeholder {
    color: #4f4c5f;
    font-size: 14px;
}

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值