html - 如何创建文本框六边形边框?

标签 html css responsive-design

  • 我想将文本框边框设置为六边形
  • 我有设计创造类似的东西。 我的代码:

#example1 {
  border: 2px solid red;
  padding: 10px;
  border-radius: 25px;
}
<div id="example1">
  <p>The border-radius property defines the radius of the element's corners.</p>
</div>

Create Border like this

最佳答案

这是一个具有多重背景的想法。代码取 self 的在线生成器:https://css-generators.com/custom-corners/

input {
  --c: red;

  width:300px;
  height:50px;
  padding:5px;
  box-sizing:border-box;
  border:none;
  outline:0;
  background:
    linear-gradient( 45deg,#0000 9.90px, var(--c) 0 calc(9.90px +  3px), #0000 0 calc(100% - 9.90px -  3px), var(--c) 0 calc(100% - 9.90px), #0000 0),
    linear-gradient(-45deg,#0000 9.90px, var(--c) 0 calc(9.90px +  3px), #0000 0 calc(100% - 9.90px -  3px), var(--c) 0 calc(100% - 9.90px), #0000 0),
    linear-gradient(90deg ,var(--c) 6px,#0000 0) -3px 50%/100% calc(100% - 28px) repeat-x,
    linear-gradient(180deg,var(--c) 6px,#0000 0) 50% -3px/calc(100% - 28px) 100% repeat-y
}
<input type="text">

关于html - 如何创建文本框六边形边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57033581/

相关文章:

html - Bootstrap - 将按钮对齐到卡片底部

html - 将 flex 元素保留在父容器中

php - html/CSS 格式中的小错误卡住 PHP 生成的 SQL 表中的第一列

html - IE 兼容性问题。图像溢出到下面的线上

html - CSS - 媒体查询不在浏览器中呈现

html - 如何让 'first-name'项和它的表格在同一行

javascript - 如何在组件中使用 v-model 值

javascript - 错误消息工具提示不可见

css - 计算一条规则上多个选择器的特异性

jquery - Chrome 移动模拟器中的布局不适应