精华内容
下载资源
问答
  • html – 如何创建多边形形状div
    2021-06-17 06:04:06

    一种方法可以是将图像分成两个容器,这两个容器的大小是父级的50%,分别转换每个容器并将背景定位为看起来像是单个图像.变换可以是倾斜(在答案中使用)或基于透视的旋转.

    请注意,由于我们正在转换容器,因此我们必须将反向效果应用于实际图像,以使其看起来正常.

    .image {

    position: relative;

    height: 150px;

    width: 450px;

    overflow: hidden;

    }

    .top-container,

    .bottom-container {

    position: absolute;

    left: 0px;

    height: 50%;

    width: 100%;

    overflow: hidden;

    backface-visibility: hidden;

    }

    .top-container {

    top: 0px;

    transform-origin: right bottom;

    transform: skew(-20deg);

    }

    .bottom-container {

    bottom: 0px;

    transform-origin: right top;

    transform: skew(20deg);

    background-position: 0% 100%;

    }

    .top-container:after,

    .bottom-container:after {

    position: absolute;

    content: '';

    height: 100%;

    width: 100%;

    left: -14px; /* tan(20) * (height/2) / 2 */

    background: url(http://lorempixel.com/450/150);

    background-size: 100% 200%;

    }

    .top-container:after {

    top: 0px;

    transform: skew(20deg);

    }

    .bottom-container:after {

    bottom: 0px;

    transform: skew(-20deg);

    background-position: 0% 100%;

    }

    /* Just for demo */

    body {

    background: linear-gradient(90deg, crimson, indianred, purple);

    }

    .image2 {

    margin-top: 10px;

    height: 150px;

    width: 450px;

    background: url(http://lorempixel.com/450/150);

    }

    Original Image

    我打算建议使用SVG和clipPath,但由于Persijn已经发布了该样本,我在下面添加了一个不同版本的多边形.

    .vector {

    position: relative;

    height: 150px;

    width: 450px;

    }

    svg {

    position: absolute;

    top: 0px;

    left: 0px;

    height: 100%;

    width: 100%;

    }

    polygon {

    fill: url(#image);

    }

    /* Just for demo */

    body {

    background: linear-gradient(90deg, crimson, indianred, purple);

    }

    更多相关内容
  • 多边形图片制作工具triangulator HTML5版插件,点开直接用可以支持html5的游览器直接使用
  • 多边形图片制作

    2014-07-01 15:10:35
    是一种技术方法。用来制作多边形的网页技术方法。网页设计趋势:多边形风格设计。并向大家详细推荐个学习网址http://www.shejidaren.com/polygon-in-web-designs.html
  • 多边形制作

    2014-04-24 11:16:53
    轻松制作多边形网页风格! 效果http://www.webjx.com/files/allimg/130603/1119114.jpg
  • CSS语言:CSSSCSS确定body {display: flex;margin: 0;height: 100vh;}svg {flex: 1;}path,polygon {fill: none;stroke: currentColor;stroke-width: 3px;vector-effect: non-scaling-stroke;}polygon {color: #807...

    CSS

    语言:

    CSSSCSS

    确定

    body {

    display: flex;

    margin: 0;

    height: 100vh;

    }

    svg {

    flex: 1;

    }

    path,

    polygon {

    fill: none;

    stroke: currentColor;

    stroke-width: 3px;

    vector-effect: non-scaling-stroke;

    }

    polygon {

    color: #807F85;

    }

    path {

    color: mediumspringgreen;

    }

    form {

    position: absolute;

    left: 0;

    padding: .5em;

    background: #222;

    color: #ddd;

    font: 1em/2 trebuchet ms, verdana, sans-serif;

    text-align: center;

    }

    input[type='radio'] {

    position: absolute;

    left: -100vw;

    }

    input[type='radio'] + label {

    display: inline-block;

    cursor: pointer;

    }

    input[type='radio'] + label:before {

    box-sizing: border-box;

    display: inline-block;

    margin: 0 .5em;

    border: solid .125em currentcolor;

    padding: .25em;

    width: 1.5em;

    height: 1.5em;

    border-radius: 50%;

    background-clip: content-box;

    vertical-align: middle;

    content: '';

    }

    input[type='radio']:checked + label {

    color: mediumspringgreen;

    }

    input[type='radio']:checked + label:before {

    background-color: currentcolor;

    }

    input[type='range'] {

    display: block;

    margin: .5em auto 0;

    border: solid 0 transparent;

    border-width: 0 .25em;

    padding: 0;

    width: 14em;

    height: 2.25em;

    background: transparent;

    font: inherit;

    cursor: pointer;

    }

    input[type='range']::-webkit-slider-runnable-track,

    input[type='range']::-webkit-slider-thumb,

    input[type='range'] {

    -webkit-appearance: none;

    }

    input[type='range']::-webkit-slider-runnable-track {

    border: none;

    width: 14em;

    height: 0.25em;

    border-radius: 0.125em;

    background: #5c5c5c;

    }

    input[type='range']::-moz-range-track {

    border: none;

    width: 14em;

    height: 0.25em;

    border-radius: 0.125em;

    background: #5c5c5c;

    }

    input[type='range']::-ms-track {

    border: none;

    width: 14em;

    height: 0.25em;

    border-radius: 0.125em;

    background: #5c5c5c;

    color: transparent;

    }

    input[type='range']::-webkit-slider-thumb {

    margin-top: -0.625em;

    box-sizing: border-box;

    border: solid 0.25em #222;

    width: 1.5em;

    height: 1.5em;

    border-radius: 50%;

    background: #5c5c5c;

    transition: .3s;

    }

    input[type='range']::-moz-range-thumb {

    box-sizing: border-box;

    border: solid 0.25em #222;

    width: 1.5em;

    height: 1.5em;

    border-radius: 50%;

    background: #5c5c5c;

    transition: .3s;

    cursor: ew-resize;

    }

    input[type='range']::-ms-thumb {

    margin-top: 0;

    box-sizing: border-box;

    border: solid 0.25em #222;

    width: 1.5em;

    height: 1.5em;

    border-radius: 50%;

    background: #5c5c5c;

    transition: .3s;

    }

    input[type='range']::-ms-fill-lower,

    input[type='range']::-ms-fill-upper {

    background: transparent;

    }

    input[type='range']::-ms-tooltip {

    display: none;

    }

    input[type='range'] + label {

    display: block;

    padding-bottom: 1em;

    }

    input[type='range']:focus {

    outline: none;

    }

    input[type='range']:focus::-webkit-slider-thumb {

    border-width: 0;

    background: mediumspringgreen;

    }

    input[type='range']:focus::-moz-range-thumb {

    border-width: 0;

    background: mediumspringgreen;

    }

    input[type='range']:focus::-ms-thumb {

    border-width: 0;

    background: mediumspringgreen;

    }

    input[type='range'][max='1']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/1) 100%;

    }

    input[type='range'][max='1']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/1) 100%;

    }

    input[type='range'][max='1']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/1) 100%;

    }

    input[type='range'][max='1'][id='s'] {

    width: 3em;

    }

    input[type='range'][max='1'][id='s']::-webkit-slider-runnable-track {

    width: 3em;

    }

    input[type='range'][max='1'][id='s']::-moz-range-track {

    width: 3em;

    }

    input[type='range'][max='1'][id='s']::-ms-track {

    width: 3em;

    }

    input[type='range'][max='2']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/2) 100%;

    }

    input[type='range'][max='2']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/2) 100%;

    }

    input[type='range'][max='2']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/2) 100%;

    }

    input[type='range'][max='2'][id='s'] {

    width: 4.5em;

    }

    input[type='range'][max='2'][id='s']::-webkit-slider-runnable-track {

    width: 4.5em;

    }

    input[type='range'][max='2'][id='s']::-moz-range-track {

    width: 4.5em;

    }

    input[type='range'][max='2'][id='s']::-ms-track {

    width: 4.5em;

    }

    input[type='range'][max='3']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/3) 100%;

    }

    input[type='range'][max='3']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/3) 100%;

    }

    input[type='range'][max='3']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/3) 100%;

    }

    input[type='range'][max='3'][id='s'] {

    width: 6em;

    }

    input[type='range'][max='3'][id='s']::-webkit-slider-runnable-track {

    width: 6em;

    }

    input[type='range'][max='3'][id='s']::-moz-range-track {

    width: 6em;

    }

    input[type='range'][max='3'][id='s']::-ms-track {

    width: 6em;

    }

    input[type='range'][max='4']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/4) 100%;

    }

    input[type='range'][max='4']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/4) 100%;

    }

    input[type='range'][max='4']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/4) 100%;

    }

    input[type='range'][max='4'][id='s'] {

    width: 7.5em;

    }

    input[type='range'][max='4'][id='s']::-webkit-slider-runnable-track {

    width: 7.5em;

    }

    input[type='range'][max='4'][id='s']::-moz-range-track {

    width: 7.5em;

    }

    input[type='range'][max='4'][id='s']::-ms-track {

    width: 7.5em;

    }

    input[type='range'][max='5']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/5) 100%;

    }

    input[type='range'][max='5']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/5) 100%;

    }

    input[type='range'][max='5']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/5) 100%;

    }

    input[type='range'][max='6']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/6) 100%;

    }

    input[type='range'][max='6']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/6) 100%;

    }

    input[type='range'][max='6']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/6) 100%;

    }

    input[type='range'][max='7']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/7) 100%;

    }

    input[type='range'][max='7']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/7) 100%;

    }

    input[type='range'][max='7']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/7) 100%;

    }

    input[type='range'][max='8']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/8) 100%;

    }

    input[type='range'][max='8']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/8) 100%;

    }

    input[type='range'][max='8']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/8) 100%;

    }

    input[type='range'][max='9']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/9) 100%;

    }

    input[type='range'][max='9']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/9) 100%;

    }

    input[type='range'][max='9']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/9) 100%;

    }

    input[type='range'][max='10']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/10) 100%;

    }

    input[type='range'][max='10']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/10) 100%;

    }

    input[type='range'][max='10']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/10) 100%;

    }

    input[type='range'][max='11']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/11) 100%;

    }

    input[type='range'][max='11']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/11) 100%;

    }

    input[type='range'][max='11']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/11) 100%;

    }

    input[type='range'][max='12']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/12) 100%;

    }

    input[type='range'][max='12']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/12) 100%;

    }

    input[type='range'][max='12']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/12) 100%;

    }

    input[type='range'][max='13']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/13) 100%;

    }

    input[type='range'][max='13']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/13) 100%;

    }

    input[type='range'][max='13']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/13) 100%;

    }

    input[type='range'][max='14']:focus::-webkit-slider-runnable-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/14) 100%;

    }

    input[type='range'][max='14']:focus::-moz-range-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/14) 100%;

    }

    input[type='range'][max='14']:focus::-ms-track {

    background-image: radial-gradient(circle at 0 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%), radial-gradient(circle at 100% 50%, #ffffff 0.125em, rgba(0, 0, 0, 0) 0%);

    background-position: 0.75em 50%;

    background-size: calc((100% - 1.5em)/14) 100%;

    }

    input.hid,

    [id='t0']:checked ~ input.hid + label {

    display: none;

    }

    展开全文
  • 纯css构造多边形div

    2021-06-28 01:17:51
    然后,因为我们需要一共是3个多边形,所以还需要增加一个before,一个after伪元素。最后的完整代码就是这样的: html部分: 内容内容内容 css部分: .polygon-content { background-color: #184284; padding: 5px; ...

    设计师画的方案里有如下的图形:

    620782740-5791c17f474a5_articlex

    如果只是一个简单的五边形,可以用css shape去做。仔细分析图形,发现它实际上是3个五边形的叠加:1. 最外面一层浅蓝色的稍大一些,2. 中间一层深蓝色颜色和背景相同,但尺寸略小,盖在下面那层上,由此而产生了一个边框的效果,3. 最里面的五边形颜色最深。所以一共是这么3层形状差不多的五边形。

    我最开始的想法是先画一个深蓝色的矩形,然后用背景色做一个小三角形盖在右下角就可以了。也确实实现了,但是画不出边框来了,感觉不够完美。

    最后还是决定用稍微麻烦一些的clip path去实现。

    第一步,先用clip path画出五边形。为了简单起见,找一个网站先把路径画出来。左下角的代码是这样的:

    -webkit-clip-path: polygon(74px 64px,70px 313px,248px 315px,311px 240px,309px 52px);

    因为我们的图形画的不规整,所以数字比较奇怪,把它整理的整齐一些:

    -webkit-clip-path: polygon(70px 70px,70px 315px,240px 315px,315px 240px,315px 70px);

    调整为以0为起点:

    -webkit-clip-path: polygon(0px 0px,0px 315px,240px 315px,315px 240px,315px 0px);

    再调整为百分比:

    -webkit-clip-path: polygon(0% 0%,0% 100%,240px 100%,100% 240px,100% 0%);

    在这里240px不能直接变为百分比,否则图像会失真。正确的做法是使用calc:

    -webkit-clip-path: polygon(100% 0%,100% calc(100% - 20px),calc(100% - 20px) 100%,0px 100%,0% 0%);

    然后,因为我们需要一共是3个多边形,所以还需要增加一个before,一个after伪元素。最后的完整代码就是这样的:

    html部分:

    内容内容内容

    css部分:

    .polygon-content {

    background-color: #184284;

    padding: 5px;

    position: relative;

    z-index: 300;

    -webkit-clip-path: polygon(100% 0%,100% calc(100% - 20px),calc(100% - 20px) 100%,0px 100%,0% 0%);

    }

    .aboutus-event-polygon:before {

    background-color: #006ec8;

    content: '';

    height: 100%;

    left: 10px;

    position: absolute;

    top: 10px;

    width: 100%;

    z-index: 200;

    -webkit-clip-path: polygon(100% 0%,100% calc(100% - 20px),calc(100% - 20px) 100%,0px 100%,0% 0%);

    }

    .aboutus-event-polygon:after {

    background-color: #2b9bd7;

    content: '';

    height: calc(100% + 4px);

    left: 12px;

    position: absolute;

    top: 8px;

    width: 100%;

    z-index: 100;

    -webkit-clip-path: polygon(100% 0%,100% calc(100% - 22px),calc(100% - 22px) calc(100% + 2px),0px calc(100% + 2px),0% 0%);

    }

    展开全文
  • JavaScript语言:JaveScriptBabelCoffeeScript确定Object.getOwnPropertyNames(Math).map(function(p) {window[p] = Math[p];});if (!hypot) {var hypot = function(x, y) {return sqrt(pow(x, 2) + pow(y, 2));...

    JavaScript

    语言:

    JaveScriptBabelCoffeeScript

    确定

    Object.getOwnPropertyNames(Math).map(function(p) {

    window[p] = Math[p];

    });

    if (!hypot) {

    var hypot = function(x, y) {

    return sqrt(pow(x, 2) + pow(y, 2));

    };

    }

    var N_SHAPES_DIM = 8,

    SHAPE_SIZE = 64,

    GUTTER = 8,

    shapes = [],

    n_shapes,

    r_max = (SHAPE_SIZE - GUTTER) / 2,

    assembly_diag = (N_SHAPES_DIM - 1) * SHAPE_SIZE,

    c = document.querySelector('canvas'),

    w, h, g,

    ctx = c.getContext('2d'),

    t = 0,

    r_id = null;

    var Shape = function(o) {

    this.o = o || {

    'x': 0,

    'y': 0

    };

    this.d = hypot(this.o.x, this.o.y);

    this.φ = (this.d / (assembly_diag / 2)) * PI;

    this.n = 3;

    this.α = 2 * PI / this.n;

    this.draw = function(ctxt) {

    var r = r_max * (1 + sin(t * PI / 120 + this.φ)) / 2,

    β, x, y;

    if (r < 1 && t % 5 != 0) {

    this.n++;

    if (this.n > 8) this.n = 3;

    this.α = 2 * PI / this.n;

    }

    ctxt.beginPath();

    for (var i = 0; i < this.n; i++) {

    β = i * this.α + t * PI / 120 + PI / 2 + this.φ;

    x = this.o.x + r * cos(β);

    y = this.o.y + r * sin(β);

    ctxt.arc(x, y, r_max - r,

    β - this.α / 2, β + this.α / 2);

    }

    ctxt.closePath();

    ctxt.fill();

    //ctxt.stroke();

    };

    };

    var init = function() {

    var s = getComputedStyle(c),

    n = 10,

    k,

    x, y;

    w = c.width = s.width.split('px')[0];

    h = c.height = s.height.split('px')[0];

    if (r_id) {

    cancelAnimationFrame(r_id);

    r_id = null;

    }

    shapes = [];

    ctx.translate(w / 2, h / 2);

    ctx.strokeStyle = '#fff';

    ctx.lineWidth = 4;

    g = ctx.createLinearGradient(0, -h / 2, 0, h / 2);

    for (var i = 0; i <= n; i++) {

    k = i / n;

    g.addColorStop(k, 'hsl(' + k * 360 + ',100%,75%)');

    }

    for (var i = 0; i < N_SHAPES_DIM; i++) {

    y = (i - N_SHAPES_DIM / 2 + .5) * SHAPE_SIZE;

    for (var j = 0; j < N_SHAPES_DIM; j++) {

    x = (j - N_SHAPES_DIM / 2 + .5) * SHAPE_SIZE;

    shapes.push(new Shape({

    'x': x,

    'y': y

    }));

    }

    }

    n_shapes = shapes.length;

    draw();

    };

    var draw = function() {

    ctx.clearRect(-w / 2, -h / 2, w, h);

    ctx.globalAlpha = 1;

    ctx.fillStyle = g;

    ctx.rect(-w / 2, -h / 2, w, h);

    ctx.fill();

    ctx.fillStyle = '#000';

    ctx.globalAlpha = .32;

    for (var i = 0; i < n_shapes; i++) {

    shapes[i].draw(ctx);

    }

    t++

    r_id = requestAnimationFrame(draw);

    };

    setTimeout(function() {

    init();

    addEventListener('resize', init, false);

    }, 15);

    展开全文
  • javascript - 如何在HTML5画布上绘制多边形?我需要知道如何在画布上绘制多边形。 不使用jQuery或类似的东西。9个解决方案137 votes创建一个moveTo和lineTo(实时演示)的路径:var ctx = canvas.getContext('2d');ctx...
  • CSS制作图形速查表

    2021-06-12 18:54:12
    前面在《纯CSS制作的图形效果》一文中介绍了十六种CSS画各种不同图形的方法。今天花了点时间将这方面的制作成一份清单,方便大家急用时有地方可查。别的不多说了,直接看代码。为了节省时间,下面图形都采用的一个...
  • html5新增的绘图标签Canvas,逐像素进行渲染,可以通过JavaScript在网页上绘制任意2D图形。 使用路径绘制自定义形状 <!doctype html> <html> <head> <meta charset="utf-8"> <title>...
  • 我正在尝试为我使用clip-path:多边形CSS属性塑造的div设置样式.我想给它一些阴影,使它看起来有点三维.问题是shadow属性不起作用.当我在浏览器中检查元素时,阴影的CSS代码显示为灰色.我尝试通过以下方式制作阴影,但...
  • D3泰森多边形

    2019-12-06 16:09:27
    D3泰森多边形D3泰森多边形示例代码界面效果 D3泰森多边形示例代码 <!DOCTYPE html> <meta charset="utf-8"> <style> .triangles { fill: none; } .links { stroke: #000; } .sites { fill: ...
  • DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>直角三角</...
  • HTML5Canvas制作雷达图实战。雷达图又叫蜘蛛网图,是一种对各项数据查看很明显的表现图,在很多游戏中,对游戏中的每个角色的分析图一般也用这种图。下面,用HTML5的Cavas来实现雷达图。效果一、创建Canvasvar mW = ...
  • 这是一款使用SVG来制作多边形图片网格布局。该布局中通过SVG来将屏幕划分为多个多边形,每个多边形中设置一张背景图片,效果非常不错。
  • html页面绘制热区工具

    2018-08-21 10:40:42
    可以在html绘制矩形、圆形、图片等形状,形成热区坐标。
  • 使用css边框绘制加 transform: skewX(45deg);属性实现 <!...css多边形</title> <style> .div { width: 100px; height: 0; border-width: 0 45px 45px; borde
  • 1.画梯形:width: 200px;height: 0px;border-top: 0px;border-bottom: 70px solid #1E6AA4;border-right: 50px solid transparent;border-left: 50px solid transparent; 2....height: 0px;border-color: #...
  • 在krpano制作全景时,我们有时候会用到多边形选区。遇到过多边形选区不显示的问题。这多数是Flash导致的。下面整理了一些解决办法。 1、首先我们是在代码中插入编辑器插件,准备编辑多边形热点或图片视频热点,...
  • 动漫制作软件哪些好用?动漫制作软件推荐!零基础学动漫哪款软件最好用?动漫设计师往往决定着作品在视觉上的最终呈现效果,一套好的制作工具绝对堪称是动漫设计师的绝佳助手。但由于动漫创作过程纷繁庞杂,且受限于...
  • 我想用纯Javascript语言通过鼠标处理程序在画布上绘制很多多边形 ....当我开始新的绘制时,在制作前向多边形添加新点 . 谢谢 .我的html文件在这里:Orhan ALTINcanvas{border: 5px solid;border...
  • 我一直在尝试拍摄我正在制作的 Map "screenshot",并且终于能够通过使用html2canvas和答案from this previous SO post.的组合来实现它 .但是,在 Map 上绘制多边形或折线时(使用绘图管理器或google.maps.polygon),...
  • 本教程是一篇关于用3ds max来制作多边形小狗建模的简易教程,介绍地很详细,制作出来的狗很有特色,转发过来,感兴趣的朋友可以过来学习一下! 建立一个BOX,把物体放到空间原点上(这样在以后调节中间点的时侯...
  • css clip-path画带边框梯形多边形项目案例一(自适应梯形)项目案例二(渐变色多边形)项目案例一(自适应梯形)如下梯形区域为模块的title信息,要求title文字个数变化时梯形区域随之变化 实现方法:两个div嵌套,外层div...
  • GIS 案例教程-蜂窝多边形制作模型 联系方式:向日葵,135-4855-4328,xiexiaokui#qq.com 优点: 拖放式,非编程,复制即用,不用配置。 效率高,非迭代,可以处理大数据。 超灵活,无限制,任意...
  • 直角三角形:更改左右大小即可掌握三角形制作即可制作其他三角形状 从代码可以看出上边为 0px 上边对应底边颜色为红色 其他边的颜色为透明色 其他边的大小为150px <!DOCTYPE html> <html lang="en"&...
  • 插件功能 绘制自定义多边形热点 热点的增删改查 各个点的拖动编辑 自定义热点颜色 获取绘制热点的坐标 js添加热点坐标 插件GIF 源码带注释 需要的加vx:zwh153577

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 5,960
精华内容 2,384
关键字:

HTML制作多边形