美文网首页
常用的css样式

常用的css样式

作者: 陪你一场 | 来源:发表于2025-04-08 11:50 被阅读0次

1、使用 Tailwind CSS 隐藏滚动条

/* global styles/global.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer utilities {
  /* 隐藏 Chrome, Safari 和 Opera 的滚动条 */
  .no-scrollbar::-webkit-scrollbar {
    display: none;
  }
  /* 隐藏 IE, Edge 和 Firefox 的滚动条 */
  .no-scrollbar {
    -ms-overflow-style: none;  /* IE 和 Edge */
    scrollbar-width: none;  /* Firefox */
  }
}

在代码中使用

 <div class="flex-1 overflow-y-scroll no-scrollbar"></div>

2、如何画出0.5px边框

方法一:使用伪元素和 transform
一种常见的解决方案是使用 CSS 的伪元素 (::before 或 ::after) 和 transform: scale() 来模拟 0.5px 的边框。具体步骤如下:

创建一个相对定位的父元素。
在父元素内部创建一个绝对定位的伪元素。
为伪元素设置 1px 的边框。
使用 transform: scale(0.5) 将伪元素缩小 50%。
设置 transform-origin: 0 0 确保缩放中心在元素的左上角。

      .box {
        width: 200px;
        height: 100px;
        margin: 20px auto;
        position: relative;
        background-color: #f0f0f0;
      }

      .box::before {
        content: '';
        position: absolute;
        width: 200%;
        height: 200%;
        left: 0;
        top: 0;
        border: 1px solid red; /* 边框颜色 */
        transform: scale(0.5);
        transform-origin: 0 0;
      }

方法二:使用双重边框
另一种方法是使用两个重叠的 1px 边框,其中一个设置为半透明,来模拟 0.5px 的边框效果。这可以通过以下 CSS 实现:

   .double-border {
        width: 200px;
        height: 100px;
        margin: 20px auto;
        border: 1px solid transparent; /* 半透明外层边框 */
        border-bottom: 1px solid blue; /* 实色底部边框 */
      }

3、css 实现文字的渐变色

.text {
    position: absolute;
    left: 52px;
    top: 1px;
    width: 200px;
    height: 31px;
    font-family: YouSheBiaoTiHei;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 31px;
    text-shadow: 0px 0px 8px #000000;
    text-align: center;
    font-style: normal;
    transition: all 0.3s;
    cursor: pointer;
    &-active {
      // 渐变文字 从上到下
      background: linear-gradient(to bottom, #ffffff 50%, #1767c4 100%);
      background-clip: text;
      color: transparent;
      text-shadow: 0px 0px 100px rgba(0, 0, 0, 0.8);
    }
  }

4、用 CSS 写一个渐变色边框的输入框

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .btn {
        width: 800px;
        height: 100px;
        display: flex;
        border-radius: 50px;
        overflow: hidden;
        position: relative;
        background: linear-gradient(
          to right,
          #ff8e10,
          #e4ca0f,
          #6ecd00,
          #00cedc,
          #204578
        );
      }
      .input {
        position: absolute;
        width: calc(100% - 10px);
        height: calc(100% - 10px);
        left: 50%;
        bottom: 50%;
        transform: translate(-50%, 50%);
        border-radius: 50px;
        background-color: #fff;
      }
    </style>
  </head>
  <body>
    <div class="btn">
      <div class="input"></div>
    </div>
  </body>
</html>

相关文章

  • day2(乱)

    css样式 1 css样式属性 #1.1 样式重置(初始化样式) 1.2 常用属性 1.3 元素水平居中 2 常用...

  • day07

    1.今天学到了 1.css常用样式的讲解 2.公共样式 2.iframe 2.CSS的常用样式 2.1.边框bor...

  • CSS 基础总结

    引入CSS 内联样式 style标签 外部样式 a.css index.html CSS之间引入(不常用) a.c...

  • CSS引入方式及选择器

    CSS层叠样式表 HTML结构和CSS样式如何关键到一起(CSS的引入方式) CSS的引入方式 CSS常用属性 C...

  • 前端Day - 02

    CSS三种样式 行间样式表 内部样式表 外部样式表 CSS基本样式 常用标签 超链接 base标签 span标签 ...

  • css function

    功能样式:css function 概述 功能样式,从常用样式方法中抽离,按需使用,使用前请先阅读 CSS规范 中...

  • HTML&CSS-day01

    A今天所学: HTML常用标签 CSS常用样式 css选择器 B所掌握到的有 全部

  • day01 html 与 css 的含义 + 常用标签 + 常用

    html 与 css 的含义 html语法结构 常用标签 css修饰语法 css常用样式 常用选择器以级优先级

  • day01

    A今日所学 一、常用HTML标签 CSS常用选择器 CSS常用样式 盒子模型 B今日已掌握 一、常用HTML标签 ...

  • day02

    知识要点梳理 1.常用的HTML标签 2.CSS常用选择器 3.CSS样式:修饰HTML网页 4.样式重置 5.水...

网友评论

      本文标题:常用的css样式

      本文链接:https://www.haomeiwen.com/subject/wkhtbjtx.html