Clip使用

简单使用 

img {
    width: 300px;
    height: 300px;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%)
}

图片如下: 

img {
    width: 300px;
    height: 300px;
    clip-path: polygon(0% 0%, 100% 100%, 50% 100%)
}

 图片如下:

 我们给出对应的点,浏览器就能进行剪裁。原点为左上角,x轴横着向右、y轴竖着向下

该网站可以非常方便的得到你想要的形状

案例一

 

    <div class="loader">
      <span class="top-half">Loading</span>
      <span class="bottom-half">Loading</span>
    </div>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.loader {
  width: 300px;
  height: 60px;
  border: 7px solid #0a3d62;
  border-radius: 10px;
  text-align: center;
  line-height: 60px;
  position: relative;
  overflow: hidden;
}

span {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 48px;
}

.top-half {
  color: #ee5253;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
  animation: split 2s linear infinite;
}

.bottom-half {
  color: #0a3d62;
  clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  animation: split 2s linear infinite reverse;
}

@keyframes split {
  0% {
    transform: translateX(100%);
  }

  40% {
    transform: translateX(0%);
  }

  60% {
    transform: translateX(0%);
  }

  100% {
    transform: translateX(-100%);
  }
}

 案例二

    <div class="wave">
      <h2>wave</h2>
      <h2>wave</h2>
    </div>

 

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #2f2f2f;
}

.wave {
  width: 500px;
  height: 500px;
  position: relative;
}

h2 {
  position: absolute;
  text-align: center;
  line-height: 500px;
  text-transform: uppercase;
  font-size: 170px;
}

h2:nth-child(1) {
  color: #7efff5;
}

h2:nth-child(2) {
  color: #03a9f4;
  clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  animation: wave 2s ease infinite;
}

@keyframes wave {
  0% {
    clip-path: polygon(
      0 48%,
      18% 52%,
      35% 58%,
      56% 59%,
      79% 60%,
      100% 55%,
      100% 100%,
      0 100%
    );
  }
  50% {
    clip-path: polygon(
      0 55%,
      15% 62%,
      40% 60%,
      61% 58%,
      79% 53%,
      100% 45%,
      100% 100%,
      0 100%
    );
  }
  100% {
    clip-path: polygon(
      0 48%,
      18% 52%,
      35% 58%,
      56% 59%,
      79% 60%,
      100% 55%,
      100% 100%,
      0 100%
    );
  }
}

案例三

    <div class="container">
      <div class="clip clip1"></div>
      <div class="clip clip2"></div>
      <div class="clip clip3"></div>
    </div>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #2f2f2f;
}

.container {
  position: relative;
  width: 800px;
  height: 500px;
  background-color: #222;
}

.clip {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: all 0.5s;
  box-sizing: border-box;
}

.clip1 {
  background: url(./img/1.jpg);
  background-size: cover;
  background-position: center;
  clip-path: polygon(0 0, 21% 0, 45% 100%, 0 100%);
  transform: translateX(-2px);
}

.clip2 {
  background: url(./img/2.jpg);
  background-size: cover;
  background-position: center;
  clip-path: polygon(16% 0, 85% 0, 70% 100%, 33% 100%);
}

.clip3 {
  background: url(./img/3.jpg);
  background-size: cover;
  background-position: center;
  clip-path: polygon(83% 0, 100% 0, 100% 100%, 63% 100%);
}

.container:hover .clip {
  clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
}

.container .clip:hover {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

案例四

    <div class="card">
      <h1>information</h1>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur
        molestiae incidunt consectetur non quas. Eum laudantium deleniti quis
        quos consequatur ipsam fugit nisi? Ea ratione, facere rem dolore minus
        quod.
      </p>
    </div>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card {
  width: 500px;
  height: 250px;
  background-color: #c7ecee;
  padding: 20px 80px 20px 20px;
  border-radius: 10px;
  clip-path: circle(7% at 93% 20%);
  transition: all 0.5s;
}

h1 {
  margin-bottom: 20px;
}

p {
  font-size: 18px;
}

.card:hover {
  clip-path: circle(70.7% at 50% 50%);
}

案例五

    <div class="main">
      <h1>black</h1>
      <h1>white</h1>
    </div>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #c8d6e5;
}

.main {
  position: relative;
  width: 800px;
}

h1 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0;
  width: 100%;
  text-align: center;
  font-size: 220px;
  text-transform: uppercase;
  transition: all 0.5s;
}

h1:nth-child(2) {
  color: white;
  clip-path: polygon(0 0, 100% 0%, 100% 0, 0% 100%);
  background-color: #c8d6e5;
}

h1:nth-child(2):hover {
  clip-path: polygon(0 0, 100% 0%, 100% 100%, 0 100%);
}

h1:nth-child(1):hover ~ h1:nth-child(2) {
  clip-path: polygon(0 0, 100% 0%, 100% 0, 0 0);
}

案例六

      <div class="content">
        <h2>title</h2>
        <p>
          Lorem ipsum, dolor sit amet consectetur adipisicing elit. Similique
          dolorum optio nihil soluta dignissimos dicta esse enim rem magnam
        </p>
      </div>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #c8d6e5;
}

.main {
  position: relative;
  width: 800px;
}

.card {
  width: 335px;
  height: 580px;
  position: relative;
}

.img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: all 0.5s;
  clip-path: circle(70.7% at 50% 50%);
}

img {
  width: 100%;
}

.card:hover .img {
  clip-path: circle(13.9% at 50% 35%);
}

.content {
  position: absolute;
  left: 0;
  bottom: 100px;
  text-align: center;
}

h2 {
  padding: 0;
  margin: 0;
  text-transform: uppercase;
}

h2,
p {
  transform: translateY(20px);
  transition: 0.3s;
  opacity: 0;
}

.card:hover h2,
.card:hover p {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.5s;
}

案例七

 <ul>
      <li>
        <a href="#" data-text="home">home</a>
      </li>
      <li>
        <a href="#" data-text="about">about</a>
      </li>
      <li>
        <a href="#" data-text="services">services</a>
      </li>
      <li>
        <a href="#" data-text="team">team</a>
      </li>
      <li>
        <a href="#" data-text="contact">contact</a>
      </li>
    </ul>
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #c8d6e5;
}

ul {
  margin: 0;
  padding: 0;
}

li {
  list-style: none;
  margin: 10px 0px;
  position: relative;
  overflow: hidden;
}

a {
  text-decoration: none;
  display: block;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  font-size: 60px;
  font-weight: 900;
  position: relative;
  padding: 5px 10px;
  color: transparent;
}

a:before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: #262626;
  padding: 5px 0;
  clip-path: polygon(0 0, 100% 0%, 100% 50%, 0 50%);
  transition: all 0.5s;
  transition-delay: 0.25s;
}

a:after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: #262626;
  padding: 5px 0;
  clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  transition: all 0.5s;
  transition-delay: 0.25s;
}

a:hover:before {
  color: rgb(160, 0, 0);
  transform: translate(10px, -3px);
}

a:hover:after {
  color: rgb(160, 0, 0);
  transform: translate(-10px, 3px);
}

li:before {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 1px;
  background-color: #262626;
  transition: all 0.5s;
  left: -100%;
}

li:hover:before {
  left: 100%;
}

案例八

    <a href="">
      <span>button</span>
      <span>button</span>
    </a>
@import url("https://fonts.googleapis.com/css?familt=poppins:200,300,400,500,600,700,800,900&display=swap");
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "poppins", sans-serif;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #222;
}

a {
  width: 180px;
  height: 60px;
  position: relative;
}

a span {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: white;
  background-color: #4834d4;
  text-align: center;
  line-height: 60px;
  /* display: flex;
  justify-content: center;
  align-items: center; */
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 22px;
}

span:nth-child(2) {
  color: #4834d4;
  background-color: white;
  clip-path: polygon(60% 0, 100% 0, 100% 100%, 60% 100%, 38% 51%);
  transition: all 0.5s;
}

/* span:nth-child(1) {
  transition: all 0.5s;
} */

span:nth-child(2):hover {
  clip-path: polygon(0 0, 100% 0%, 100% 100%, 0 100%, 0 53%);
}

span:nth-child(1):hover ~ span:nth-child(2) {
  clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%, 100% 57%);
}

案例九

    <section>
      <div class="box box1">
        <h2><span>Bye Bye</span><span>2030</span></h2>
      </div>
      <div class="box box2">
        <h2><span>Happy New Year</span><span>2031</span></h2>
      </div>
    </section>
@import url("https://fonts.googleapis.com/css?familt=poppins:200,300,400,500,600,700,800,900&display=swap");
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "poppins", sans-serif;
}

body {
  overflow: hidden;
}

section {
  width: 100%;
  height: 100vh;
  position: relative;
}

.box {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.box2 {
  background-color: #4cb979;
  clip-path: polygon(0 0, 100% 0%, 100% 50%, 0 50%);
}

h2 {
  font-size: 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translateY(-70%);
  animation: textMove 3s ease-in-out infinite;
}

.box2 h2 {
  color: #fff;
}

span:nth-child(2) {
  line-height: 1em;
  font-size: 2em;
}

@keyframes textMove {
  0%,
  45% {
    transform: translateY(-70%);
  }

  55%,
  90% {
    transform: translateY(70%);
  }

  100% {
    transform: translateY(-70%);
  }
}

clip-path做动画,就是依靠“重叠遮盖、窗口显露”,利用元素互相遮挡、clip-path撕开口子显示不同的内容,再利用transition或者animation做出来的

### CLIP使用方法概述 CLIP 是一种多模态模型,能够同时处理文本和图像数据。其核心功能在于通过预训练的方式学习到通用的表示空间,在这个空间中可以比较文本和图像之间的相似度。 #### 图像编码过程 当输入一张图片时,CLIP 使用的是视觉模型(如 `CLIPVisionModel`),而非文本模型。此视觉模型会将图片转换为一个高维向量表示[^1]。以下是 Python 中调用 Hugging Face 提供的 CLIP 工具包来实现这一过程的一个简单示例: ```python from transformers import CLIPProcessor, CLIPModel import requests from PIL import Image model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") url = "https://example.com/sample_image.jpg" image = Image.open(requests.get(url, stream=True).raw) inputs = processor(images=image, return_tensors="pt", padding=True) outputs = model.get_image_features(**inputs) print(outputs) ``` 上述代码展示了如何利用 CLIP 将一幅图片转化为特征向量的过程。 #### 文本与图像匹配 除了单独对图像进行编码外,CLIP 还支持联合分析文本描述与对应图像间的关联程度。下面是一个综合案例,展示如何计算一组候选文字说明分别同某张目标照片的相关性得分: ```python texts = ["a photo of a cat", "a photo of a dog"] text_inputs = processor(text=texts, return_tensors="pt", padding=True) logits_per_image = outputs @ text_inputs['input_ids'].T probs = logits_per_image.softmax(dim=-1) print(probs) ``` 这里我们先准备了几条可能解释图意的文字串列表;接着借助同样的处理器对象将其转码成适配神经网络层运算的形式;最后经由矩阵乘积操作得出两组预测概率值——它们反映了各自语句诠释原片内容的可能性大小关系。 --- 关于 PHP 和 JavaScript 领域内的 phantomJS 插件配置选项部分,则主要涉及 Web 自动化测试场景下的页面抓取行为控制逻辑设置等问题讨论范围之外的内容[^2]。而 pandas 库里的 clip_upper 方法则是针对数值型列执行上限截断操作的一种便捷手段[^3],同样不属于当前主题范畴之内。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值