简体   繁体   English

如何在不改变顶部圆形边框形状的情况下取消底部圆形边框的样式?

[英]How can I unstyle bottom rounded border without changing the shape of top rounded border?

I'm trying to recreate Google.我正在尝试重新创建 Google。 When you focus on the search bar at Google.com, the bottom border will unstyle the rounded border.当您专注于 Google.com 的搜索栏时,底部边框将取消圆形边框的样式。 So I tried to make this effect by setting focus to unstyle bottom border-radius, but this will change the top border's shape.所以我尝试通过将焦点设置为无样式底部边框半径来实现此效果,但这会改变顶部边框的形状。

the code I write is roughly like this.我写的代码大致是这样的。

<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet"/>

<div class="rounded-[24px] bg-white px-3 focus-within:rounded-b-none">
      <input type="text" class="w-full outline-none" />
    </div>

I think you need to set a fixed height on the div and the rounded corners to match half of that.我认为您需要在div和圆角上设置一个固定高度以匹配其中的一半。 Like:喜欢:

<div class="h-screen w-full bg-slate-500 p-8">

  <div class="h-8 rounded-t-[1rem] rounded-b-[1rem] bg-white flex items-center px-3 focus-within:rounded-b-none">
        <input type="text" class="w-full outline-none" />
  </div>

</div>

In tailwind, h-8 equals 2rem.在顺风中, h-8等于 2rem。 I also centered the input vertically in the div with flex.我还使用 flex 在 div 中垂直居中输入。

See working tailwind play example.请参阅工作顺风播放示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM