Css 剪辑替代方案

标签 css

在下面的代码片段中查看我的案例。我已经使用 CSS clip 属性来剪切按钮的左圆 Angular 部分,但我 read此属性已被强烈弃用。没有剪辑我怎么能做同样的事情?将输入框放在按钮的顶部不会遮盖按钮的阴影。此外,clip-path 不是一个选项,因为浏览器支持不佳。

.container {
	position:relative;
	width:250px;
	height:30px;
	background-color:#e0e0e0;
	padding:10px;
}

.myButton {
	position:absolute;
	z-index:1;
	top:10px;
	left:165px;	
	box-shadow:0 2px 2px 0 #c0c0c0;
	border-radius:5px;
	border:1px solid #888;	
	font-weight:600;
	text-decoration:none !important;
	cursor:pointer;
	text-align:center;
	font-family:"Segoe UI", Arial, Helvetica, sans-serif;
	font-size:14px;
	line-height:18px;
	clip: rect(0px,100px,200px,5px);	
}

.myButton span {
	display:block;
	line-height:23px;
	height:23px;
	font-size:13px;
	padding:0 8px 0 12px	
}

.myButton {
	color:#fff;
	background:linear-gradient(to bottom,#79d1ff 0%, #389ee5 100%);	

}

.myButton:hover {
	background:linear-gradient(to bottom, #ec7ebf 0%,#d85da5 35%,#b5006c 70%,#b5006c 100%);
	color:#FFF	
}

.myInput {
	position:absolute;
	top:10px;
	width:166px;
	height:19px;
}
<div class="container">
  <input name="name" class="myInput" type="text" />
  <a href="javascript:;" class="myButton"><span>Submit</span></a>
</div>

最佳答案

简单地依靠一些负边距的溢出。这是您的代码的更新:

.container {
  position: relative;
  width: 250px;
  height: 30px;
  background-color: #e0e0e0;
  padding: 10px;
}

.myButton {
  position: absolute;
  z-index: 1;
  top: 5px;
  left: 165px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  text-align: center;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 18px;
  overflow:hidden; /*Added This code */
  padding:5px 5px 5px 0;
}

.myButton span {
  display: block;
  box-shadow: 0 2px 2px 0 #c0c0c0;
  border-radius: 5px;
  border: 1px solid #888;
  line-height: 23px;
  height: 23px;
  font-size: 13px;
  padding: 0 8px 0 12px;
  color: #fff;
  background: linear-gradient(to bottom, #79d1ff 0%, #389ee5 100%);
  margin-left:-8px; /* Added this code*/
}

.myButton:hover span {
  background: linear-gradient(to bottom, #ec7ebf 0%, #d85da5 35%, #b5006c 70%, #b5006c 100%);
  color: #FFF
}

.myInput {
  position: absolute;
  top: 10px;
  width: 166px;
  height: 19px;
}
<div class="container">
  <input name="name" class="myInput" type="text">
  <a class="myButton"><span>Submit</span></a>
</div>

关于Css 剪辑替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49481885/

相关文章:

html - 对 html 表格使用双边框,同时在单元格周围使用单实线边框

javascript - 产品上的 jQuery 输入复选框过滤器

javascript - 如何在不干扰上方内容的情况下将固定高度的 <div> 锚定到 <td> 的右下角?

css - 使用替代设置文件夹设置向 Django 显示在哪里可以找到我的静态文件

html - 调用类时不显示 div 背景色

javascript - 如何让我的复选框值和选项值相加并将总和输入到我的文本区域?

html - img 标签不适用于 src 中的相对路径

javascript - 如何以 0 秒启动 setInterval 函数但在给定时间内重复它?

javascript - 谷歌图表工具提示中的 DIV 定位

php - 搜索结果格式