25

如果我想画一条水平线,我会这样做:

<style>
#line{
    width:100px;
    height:1px;
    background-color:#000;
}
</style>
<body>
<div id="line"></div>

如果我想画一条垂直线,我会这样做:

#line{
    width:1px;
    height:100px;
    background-color:#000;
}
</style>
<body>
<div id="line"></div>

曲线比较复杂,但可以使用border-radius和包裹元素:

<style>
.curve{
    width:100px;
    height:500px;
    border:1px #000 solid;
    border-radius:100%;
}
#wrapper{
    overflow:hidden;
    width:40px;
    height:200px;
}
</style>
<body>
<div id="wrapper">
    <div class="curve"></div>
</div>
</body>

但我什至无法理解如何生成波浪线!仅使用css(和javascript,因为似乎有必要能够更轻松地生成它们),这是否甚至可以远程实现。

笔记:

正如预期的那样,鉴于您的答案,没有办法在唯一的 css 中执行此操作...javascript 和 jquery 100% 可以满足您的回答...没有图像可以使用

4

12 回答 12

33

这个问题相当古老,但我找到了一种无需 Javascript、重复 CSS 或图像的方法。

使用 background-size 你可以重复一个模式,它可以用纯 CSS 使用线性渐变或径向渐变创建。

我在这里放了一堆例子:http: //jsbin.com/hotugu/edit ?html,css,output

例子

基本要点是:

.holder {
  /* Clip edges, as some of the lines don't terminate nicely. */
  overflow: hidden;
  position: relative;
  width: 200px;
  height: 50px;
}

.ellipse {
  position: absolute;
  background: radial-gradient(ellipse, transparent, transparent 7px, black 7px, black 10px, transparent 11px);
  background-size: 36px 40px;
  width: 200px;
  height: 20px;
}

.ellipse2 {
  top: 20px;
  left: 18px;
  background-position: 0px -20px;
}
<div class="holder">
  <div class="ellipse"></div>
  <div class="ellipse ellipse2"></div>
</div>

您可以通过一些修改产生一些令人信服的波浪线:

.holder {
    position: relative;
    width: 200px;
    height: 50px;
    top: 25px;
}
.tinyLine {
    position: absolute;
    /* Cuts off the bottom half of the pattern */
    height: 20px;
    /* For better cross browser consistency, make it larger with width.  */
    width: 1000%;
    /* And then scale it back down with scale, recentering with translateX. */
    transform: translateX(-45%) scale(0.1);
}

.tinyLine1 {
    background: linear-gradient(45deg, transparent, transparent 49%, red 49%, transparent 51%);
}
.tinyLine2 {
    background: linear-gradient(-45deg, transparent, transparent 49%, red 49%, transparent 51%);
}
.tinyLine {
    /* Must be after background definition. */
    background-size: 40px 40px;
}
<div class="holder">
    <div class="tinyLine tinyLine1"></div>
    <div class="tinyLine tinyLine2"></div>
</div>

浏览器支持还可以(http://caniuse.com/#feat=css-gradients),IE 10 可能会工作,但是在不同的浏览器中会出现小规模的问题。如果您希望它在非常小的范围内始终如一地工作,您可能希望在更大的范围内制作线,然后将其缩小transform: scale(x);

它也应该非常快,线性渐变在 GPU 上以 chrome 呈现。

于 2015-01-04T10:23:13.297 回答
10

编辑: 鉴于没有图像/数据 uri 的要求。

您还可以将一堆边界半径元素塞在一起,交替禁用顶部/底部或左/右边缘。我已经将它概括为一个将它们附加到元素的函数。

Javascript,其中 squigglecount 是“squiggles”的数量。如果您愿意,可以将其概括为实际宽度。

http://jsfiddle.net/V7QEJ/1/

function makeLine(id, squiggleCount) {
  var curve;
  var lineEl = $(id);

  for (var i = 0; i < squiggleCount; i++) {
    curve = document.createElement('div');
    curve.className = 'curve-1';
    lineEl.append(curve);

    curve = document.createElement('div');
    curve.className = 'curve-2';
    lineEl.append(curve);
  }
}
$(document).ready(function(){
    makeLine('#line', 16);
});
.curve-1,
.curve-2 {
  display: inline-block;
  border: solid 1px #f00;
  border-radius: 50px;
  height: 20px;
  width: 20px;
}

.curve-1 {
  border-bottom: none;
  border-left: none;
  border-right: none;
}

.curve-2 {
  border-top: none;
  border-left: none;
  border-right: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="line">
</div>

旧(带图片):

已经有很多答案,但这里有一个简单的方法来做一条垂直的波浪线,类似于劳森的答案。

基本上,您使用背景图像和波浪线的数据 uri 来执行此操作。我可能不会将它用于任何事情,但这是一个有趣的思考练习。有一堆数据 uri 生成器,您可以在线使用它们来更改自己的图像。

http://jsfiddle.net/zadP7/

.aux{
    display: inline-block;
    vertical-align: top;
}
.line{
    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AAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAEAAAAAAAAA/wAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAP8AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACelxA/rjIgrgAAAABJRU5ErkJggg==);   
}
<div class="aux">Stuff</div>
<div class="line"></div>
<div class="aux">More Stuff</div>

于 2013-06-24T21:50:47.420 回答
8

纯 CSS 解决方案:

我们可以使用正弦波字符'∿' 字符,然后

letter-spacing

小提琴

在此处输入图像描述

只是为了好玩,我们可以使用不同的字符来获得其他曲线:

小提琴 #2

div {
  font-size: 50px;
  font-family: verdana;
}
.tilde {
  letter-spacing: -19px;
}
.ohm {
  letter-spacing: -6px;
}
.ac {
  letter-spacing: -25px;
}
.acd {
  letter-spacing: -11px;
}
.curlyv {
  letter-spacing: -12px;
}
.frown {
  letter-spacing: -13px;
}
<div class="acd">∿∿∿∿∿∿∿∿∿∿∿∿∿∿∿&lt;/div>
<div class="tilde">˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜</div>
<div class="curlyv">⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎⋎</div>
<div class="frown">⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢⌢&lt;/div>
<div class="ac">∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾∾&lt;/div>
<div class="ohm">ΩΩΩΩΩΩΩΩΩΩ</div>

于 2015-01-04T11:15:06.637 回答
6

如果您希望某些文本的下划线为波浪线,则可以使用以下 css:

span {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: red;
}
<span>Example text here</span>

来源:https ://developer.mozilla.org/en/docs/Web/CSS/text-decoration-line#example

于 2015-11-01T17:26:39.340 回答
1

如果您不是在寻找真正整洁的东西,而只是为了好玩,请使用多个 box-shadow: http ://codepen.io/gcyrillus/pen/mfGdp或http://codepen.io/gcyrillus/pen /xhqFu

.curve{
  margin:3em 0;
  width:100px;
  height:150px;
  border-radius:50%;
  box-shadow:
    0px 2px 1px -1px,
    400px 0px 0px 0px white,
    400px 2px 1px -1px ,
    300px 0px 0px 0px white,
    300px -2px 1px -1px,
    600px 0px 0px 0px white,
    600px 2px 1px -1px ,
    500px 0px 0px 0px white,
    500px -2px 1px -1px,
    800px 0px 0px 0px white,
    800px 2px 1px -1px ,
    700px 0px 0px 0px white,
    700px -2px 1px -1px,
    1000px 0px 0px 0px white,
    1000px 2px 1px -1px ,
    900px 0px 0px 0px white,
    900px -2px 1px -1px,
    1200px 0px 0px 0px white,
    1200px 2px 1px -1px ,
    1100px 0px 0px 0px white,
    1100px -2px 1px -1px,
    1400px 0px 0px 0px white,
    1400px 2px 1px -1px ,
    1300px 0px 0px 0px white,
    1300px -2px 1px -1px,
    1600px 0px 0px 0px white,
    1600px 2px 1px -1px ,
    1500px 0px 0px 0px white,
    1500px -2px 1px -1px;
  position:relative;
}
.curve:before,.curve:after {
  content:'';
  position:absolute;
  height:100%;
  width:100%;
  border-radius:100%;
  box-shadow:inherit;
}
.curve:before {
  left:100%;
  transform:rotate(180deg);
 }
.curve:after {
  left:200%;
}
于 2013-06-24T22:07:06.640 回答
1

﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏﹏

&#65103; (波浪低线)

我希望这不是太离题 - 这里是如何使用那些波浪线来强调一些文本(应该是一个常见的用例。)

方法1(从Wulf回答相关问题抢夺)

<span style="border-bottom: 1px dotted #ff0000;padding:1px">
    <span style="border-bottom: 1px dotted #ff0000;">
        foobar
    </span>
</span>

(不是真正的波浪线,而是一组点,但看起来不错,而且非常简单。)

方法 2(受 DanieldD 启发)

使用 & #65103 ; (波浪低线)unicode 字符和绝对/相对定位,以将该字符放在某些文本下方。这是一个小提琴

这是定位代码的“肉”

function performUnderWavyLowLineazation(contentElt){
    var wavyFontSize = 40;
    var width = contentElt.width();
    contentElt.addClass("underWavyLowLined");
    replaceSpaceByNonBreakingSpace(contentElt);
    var sp = "<span/>";
    var wrapper = contentElt.wrap(sp).parent();
    wrapper.addClass("wavyParent");
    var underlining = jQuery(sp, {"class" : "wavyLowLine"}).prependTo(wrapper);
    var ghost;
    var invisibleGhostThatTakesUpTheSpaceThatUnderWavyLowLinedElementShouldTakeButDoesntDueToBeingAbsolute
        = ghost = jQuery(sp, {"class": "invisibleUnderWavyLowLined"}).appendTo(wrapper);
    ghost.html(contentElt.html());
    ghost.find("*").removeAttr("id");
    replaceSpaceByNonBreakingSpace(ghost);
    var numWavyChars = Math.floor(0.1 + width/wavyFontSize);
    innerUnderLine = jQuery(sp, {"class": "innerWaveLine"}).appendTo(underlining);
    innerUnderLine.html("&#65103;".repeat(numWavyChars));
    var lineLength = wavyFontSize * numWavyChars;
    var defect = width - lineLength;
    innerUnderLine.css("left", defect/2);
    var wavyGroup = jQuery(sp, {"class" : "wavyGroup"}).prependTo(wrapper);
    underlining.appendTo(wavyGroup);
    contentElt.appendTo(wavyGroup);
}
于 2015-03-17T23:15:26.660 回答
1

感谢@yeerk提供了如此出色的解决方案!

但我想建议对他的第一个变体进行一些改进——对那些看起来更像三角形的波浪。我建议使用伪元素而不是硬编码的封闭 div :before:after

它可能看起来像这样(html):

<div class="triangly-line"></div>

triangly-line目标装饰元素在哪里(不是“挥手”而是“三角形”)。

相应的样式(使用 LESS 表示法)将如下所示:

@line-width: 300px;
@triangled-size: 6px;
@triangly-color: red;
@double-triangled-size: (@triangled-size * 2 - 1px);
.linear-gradient (@gradient) {
    background: -webkit-linear-gradient(@gradient);
    background: -o-linear-gradient(@gradient);
    background: linear-gradient(@gradient);
}
.triangly-gradient (@sign, @color) {
    .linear-gradient(~"@{sign}45deg, transparent, transparent 49%, @{color} 49%, transparent 51%");
}
.triangly-line {
    overflow: hidden;
    position: relative;
    height: @triangled-size;
    &:before {
        .triangly-gradient("", @triangly-color);
    }
    &:after {
        .triangly-gradient("-", @triangly-color);
    }
    &:before,
    &:after {
        content: "";
        display: block;
        position: absolute;
        width: @line-width;
        height: @triangled-size;
        background-size: @double-triangled-size @double-triangled-size !important;
    }
}

结果 CSS(使用上面指定的参数):

.triangly-line {
    overflow: hidden;
    position: relative;
    height: 6px;
}
.triangly-line:before {
    background: -webkit-linear-gradient(45deg, transparent, transparent 49%, red 49%, transparent 51%);
    background: -o-linear-gradient(45deg, transparent, transparent 49%, red 49%, transparent 51%);
    background: linear-gradient(45deg, transparent, transparent 49%, red 49%, transparent 51%);
}
.triangly-line:after {
    background: -webkit-linear-gradient(-45deg, transparent, transparent 49%, red 49%, transparent 51%);
    background: -o-linear-gradient(-45deg, transparent, transparent 49%, red 49%, transparent 51%);
    background: linear-gradient(-45deg, transparent, transparent 49%, red 49%, transparent 51%);
}
.triangly-line:before,
.triangly-line:after {
    content: "";
    display: block;
    position: absolute;
    width: 300px;
    height: 6px;
    background-size: 11px 11px !important;
}
于 2015-12-28T22:04:26.297 回答
0

不要使用边框,而是使用平铺的背景图像。

我认为没有一种解决方案可以在不使用图形文件的情况下消失,并且也适用于所有浏览器。

如果你很勇敢,你可以试试这个:http ://www.html5canvastutorials.com/tutorials/html5-canvas-arcs/

它允许在 HTML5 的画布上绘图,但它不适用于旧版浏览器。

如果你可以添加很多 html 你可以使用这个:http: //jsfiddle.net/QsM4J/

HTML:

<body>
    <p>
    before
    </p>
    <div id="sqig">
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
        <div class="topsqig"><div></div></div>
        <div class="bottomsqig"><div></div></div>
    </div>
    <p>
    after
    </p>
</body>   

CSS:

#sqig{
    position:relative;
    width:400px;
    height:6px;
}
#sqig div{
    position:relative;
    width:6px;
    height:6px;
    display: inline-block;
    margin:0 0 0 -4px;
    padding:0;    
}
#sqig .topsqig div{
    border-radius: 3px;
    top:1px;
    border-top: 1px solid #000;
}
#sqig .bottomsqig div{
    border-radius: 3px;
    top:-1px;
    border-bottom: 1px solid #000;
}
于 2013-06-24T21:39:32.083 回答
0

在 HTML5 和 Canvas 出现之前,有JavaScript VectorGraphics。如果您想在纯 HTML 中绘制圆形、椭圆等,您可能想尝试一下。

于 2013-06-24T21:44:44.753 回答
0

我找到了一种更好的方法来在 CSS 中实现三角形波浪线,而无需将高度减半或应用在浏览器中无法正常工作的技巧。

结果

我尝试了@yeerk 的解决方案,但它只在 Chrome 中运行良好。这些行在 Safari 和 Firefox 上有工件。

火狐

火狐神器

苹果浏览器

野生动物园神器

此解决方案是@liliputen 解决方案的变体,但它提高了灵活性。

您可以从background-size属性中轻松更改线条的大小。

.squiggly {
    position: relative;
    height: 10px;
    width: 100%;
}

.squiggly::after,
.squiggly::before {
    height: inherit;
    width: inherit;
    background-size: 12px 100%; /* Change this to adjust the size of the squiggly line. */
    content: "";
    position: absolute;
}

.squiggly::before {
    top: -2px;
    background-image: linear-gradient(45deg, red 35%, transparent 0),
        linear-gradient(-45deg, red 35%, transparent 0);
}

.squiggly::after {
    top: 0px;
    background-image: linear-gradient(45deg, white 35%, transparent 0),
        linear-gradient(-45deg, white 35%, transparent 0);
}
<div class="squiggly"></div>

您也可以在JS Fiddle上找到它。

于 2021-01-25T12:21:36.527 回答
0

这是一个基于@yeerk答案的 SASS 波浪线生成器。如果您想要三角形,请使用上面的生成器@lilliputten

$waveHeight: 40px;
$waveLength: 70px;
$waveRadius: 13px; // adjust depending on length
$waveThickness: 8px;

@mixin waveSide() {
  position: absolute;
  background: radial-gradient(ellipse, transparent, transparent $waveRadius, black $waveRadius, black #{$waveRadius + $waveThickness}, transparent #{$waveRadius + $waveThickness});
  background-size: #{$waveLength} #{$waveHeight * 2};
  height: $waveHeight;
}

.wavy {
  width: 400px; // give the wave element a length here

  @include waveSide;

  &::before {
    $waveOffset: $waveLength / 2;
    @include waveSide;

    content: '';
    width: calc(100% - #{$waveOffset});
    top: $waveHeight;
    left: $waveOffset;
    background-position: 0px -#{$waveHeight};
  }
}
于 2018-11-21T15:11:18.213 回答
-1

如果您使用的是 Javascript,则可以使用正弦波轻松实现 - 这就是几十年来编程语言实现可控波浪线的方式!你应该可以找到很多例子,但本质上你只是用递增的 x 值循环并应用正弦函数 sin()。这在 90 年代用于制作屏幕保护程序并为其制作动画等非常酷。

于 2013-06-24T21:46:05.743 回答