html - CSS:是否可以使元素看起来像正弦/余弦函数?

标签 html css

在我的页面上,我希望元素以与 hr 元素相同的方式用作水平“中断”,但我希望它们的形状像正弦函数。

这可能吗?如果是这样,如何?

这里有一个 fiddle 供您完成:http://jsfiddle.net/pdov7u85/

HTML:

<p>Here's some red text</p>
<!--some element with id someElement will go here-->
 <p>Here's some blue text, which should be divided from the red text with a wavy line</p>

CSS:

p:nth-of-type(1)
{
    color: red;
}

#someElement
{

}

p:nth-of-type(2)
{
    color: blue;
}

最佳答案

接受挑战。

.sine { 
	text-align: center;
}
.sine_span {
	display: inline-block;
	margin:0;
	padding:0;
	height: 20px;
	width: 40px;
	border: 1px solid black;
}
.sine_span_first {
	border-bottom: none;
	border-radius: 20px 20px 0 0;
	transform: translate(-20px, 0) scale(2,1);
}
.sine_span_second {
	border-top: none;
	border-radius: 0 0 20px 20px;
	transform: translate(20px, 20px) scale(2,1);
}
.sine_span_first_2 {
  transform: translate(0, 20px) scale(1,2);
}
.sine_span_second_2 {
  transform: translate(0, 60px) scale(1,2);
}
Flat curve
<div class="sine">
  <span class="sine_span sine_span_first"></span><span class="sine_span sine_span_second"></span>
</div>

<br />
Sharp curve
<div class="sine">
  <span class="sine_span sine_span_first sine_span_first_2"></span><span class="sine_span sine_span_second sine_span_second_2"></span>
</div>

顺便说一句,你不应该为此使用一些 gif 图像吗?

关于html - CSS:是否可以使元素看起来像正弦/余弦函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26575797/

相关文章:

jquery - 仅 300 像素高的页脚有视差效果?

javascript - JQuery 通过 JQuery 对话框删除 html

html - CSS 流体布局 : "stacked" div with different heights

javascript - 获取主菜单项列表

html - 导航栏 - 固定位置

html - 垂直对齐div中的图像

html - 如何使用 css3 动画将宽度和高度设置为 100%?

javascript - 滚动固定的 div 时防止正文滚动?

html - 带有拆分按钮下拉菜单的 Bootstrap 选项卡

html - 在父悬停时更改子 div 位置