Design and UI element using html, CSS and supplied glyphs - html
So I am given one element that has glyph icons and am asked to code it using html, css and supplied font. Now each glyph icon has codes and ligatures. Can anyone help me with it? what should be my approach to start coding that element.
SVG
The given shape can be created with SVG.
You will have to learn a lot of SVG to create complex shapes.
I would start at the basics
.widget {
width: 300px;
height: 300px;
}
.pill {
stroke: #999;
stroke-width: 1;
}
.pill .top {
fill: Orange;
}
.pill .bottom {
fill: LightSeaGreen;
}
.pill .circ-outer {
fill: rgb(120, 50, 120);
}
.pill .circ-inner {
stroke: none;
fill: white;
}
.pill .cross {
stroke: rgb(120, 50, 120);
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
fill: none;
}
.handle {
stroke: #999;
fill: #555;
}
.ribble {
stroke: #777;
stroke-linecap: round;
stroke-linejoin: round;
}
<svg class="widget" viewBox="0 0 100 100">
<defs>
<filter id="drop">
<feOffset in="SourceAlpha" dx="0" dy="0.2" result="off" />
<feGaussianBlur result="blurOut" in="off" stdDeviation="0.5" />
<feBlend in="SourceGraphic" in2="blurOut" />
</filter>
</defs>
<path class="handle" d="m35,16
a 5 10 0 0 1 0,70"/>
<line class="ribble" x1="43" y1="43" x2="43" y2="57" filter="url(#drop)"/>
<line class="ribble" x1="45" y1="45" x2="45" y2="55" filter="url(#drop)"/>
<line class="ribble" x1="47" y1="47" x2="47" y2="53" filter="url(#drop)"/>
<g class="pill">
<path class="top" d="m10,50 0,-30
a 5 5 0 0 1 30 0 v 30" />
<path class="bottom" d="m10,50 0,30
a 5 5 0 0 0 30 0 v -30" />
<circle class="circ-outer" cx="25" cy="50%" r="15" />
<circle class="circ-inner" cx="25" cy="50%" r="10" filter="url(#drop)" />
<polyline class="cross" points="30,50 20,50 25,50 25,55 25,45" />
</g>
</svg>
For glyphicons you can refer this link
For example: we can write is like:
<p>Envelope icon: <span class="glyphicon glyphicon-envelope"></span></p>
Please see the below link for more details
http://www.w3schools.com/bootstrap/bootstrap_ref_comp_glyphs.asp
http://getbootstrap.com/components/
Without bootstrap:
<div class="inner-addon left-addon">
<i class="glyphicon glyphicon-user"></i>
<input type="text" class="form-control" />
</div>
In CSS
/* enable absolute positioning */
.inner-addon {
position: relative;
}
/* style icon */
.inner-addon .glyphicon {
position: absolute;
padding: 10px;
pointer-events: none;
}
/* align icon */
.left-addon .glyphicon { left: 0px;}
.right-addon .glyphicon { right: 0px;}
/* add padding */
.left-addon input { padding-left: 30px; }
.right-addon input { padding-right: 30px; }
Got this from this:
Add Bootstrap Glyphicon to Input Box
I have tried to make replica based on your image. Try to add Search, Home and Plus icons to head-glyph , middle-glyph , tail -glyph div's to look little bit similar to your image.
CSS
.glyph {
display:block;
border:3px solid #bbb;
height:120px;
width:50px;
position:absolute;
background:grey;
border-radius:24px;
z-index:100;
}
.head-glyph {
border-radius:20px;
background:orange;
height:70px;
width:50px;
position:absolute;
z-index:200;
display:block;
}
.middle-glyph{
border-radius:25px;
background:#660066;
height:50px;
width:50px;
border:2px solid #bbb;
position:absolute;
z-index:300;
top:35;
left:-3;
display:block;
}
.middle-glyph-tiny{
border-radius:25px;
background:white;
height:35px;
width:35px;
position:absolute;
z-index:300;
top:8;
left:8;
display:block;
box-shadow: 0 0 5px #888;
}
.tail-glyph {
border-radius:20px;
background:skyblue;
height:70px;
width:50px;
position:absolute;
z-index:200;
bottom:0;
}
.half-circle {
position:absolute;
z-index:10;
height:118px;
width:55px;
border-radius: 0px 60px 60px 0px;
background:grey;
left:15;
top:-2;
border:3px solid #bbb;
}
HTML
<div class="glyph">
<div class="head-glyph"></div>
<div class="middle-glyph">
<div class="middle-glyph-tiny"></div>
</div>
<div class="tail-glyph"> </div>
<div class="half-circle"> </div>
</div>
http://jsbin.com/vumurafuwa/2/edit
since you're going to probably to need to register click events, I've used a couple of elements to allow for this:
Please note this is only for semantic purposes only
.wrap {
position: relative;
width: 75px;
height: 200px;
border-radius: 100px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border: 3px solid darkgray;
margin: 50px;
background: lightgray;
z-index: 8;
box-shadow: 0 0 20px 10px black;
cursor: pointer;
}
.wrap:before {
content: "";
position: absolute;
left: 0;
width: 140%;
top: 8%;
height: 84%;
border-radius: 50%;
background: gray;
border: 3px solid darkgray;
}
.wrap:after {
content: "";
position: absolute;
width: 0;
border: 3px ridge darkgray;
border-radius: 3px;
height: 10%;
top: 45%;
left: 110%;
}
.middle:hover:before {
background: lightgray;
}
.top {
content: "";
position: absolute;
top: 0;
left: 0;
height: 50%;
width: 100%;
border-radius: 75px 75px 0 0;
background: orange;
transition: all 0.4s;
}
.top:before,
.bottom:before {
content: "";
position: absolute;
background: url(http://bahriadirectory.com/wp-content/uploads/2014/07/Very-Basic-Search-icon.png) no-repeat;
background-size: 40px 40px;
height: 50px;
width: 50px;
left: 10px;
}
.top:before {
top: 10px;
}
.bottom:before {
bottom: 5px;
}
.bottom:before {
background: url(http://www.wheatonbible.org/Content/10713/Icons/home-icon.png) no-repeat;
left: 8px;
background-size: 50px 50px;
}
.bottom {
content: "";
position: absolute;
top: 50%;
left: 0;
height: 50%;
width: 100%;
border-radius: 0 0 75px 75px;
background: cornflowerblue;
transition: all 0.4s;
}
.top:hover,
.bottom:hover {
background: lightgray;
}
.middle {
position: absolute;
height: 67px;
width: 100%;
border-radius: 50%;
border: 3px solid lightgray;
top: 50%;
left: -3px;
transform: translateY(-50%);
background: purple;
}
.middle:before {
content: "";
position: absolute;
top: 10%;
left: 10%;
background: white;
border-radius: 50%;
height: 80%;
width: 80%;
box-shadow: 5px 5px 5px 0 #222;
transition: all 0.4s;
}
.middle:after {
content: "+";
position: absolute;
top: 50%;
lefT: 50%;
transform: translate(-50%, -50%);
color: purple;
font-family: arial;
font-size: 80px;
}
html,
body {
margin: 0;
padding: 0;
background: #222;
}
<div class="wrap">
<div class="top"></div>
<div class="bottom"></div>
<div class="middle"></div>
</div>
Please note
I have used images for the search and home icons. These can be altered by using font icons/etc.
Related
Rectangle border with specific length
I'm trying to create the following using html and css It's rectangle with with border that has specific length, starting from top center, the length around the rectangle should specify with percentage, so the left rectangle should have border with length of 30%, the right should have 45% more or less. I tried many things like gradient without success
.box { height: 150px; width: 150px; background-color: red; border-radius: 8px; position: relative; overflow: hidden; } .box-top { display: block; position: absolute; background-color: blue; height: 8px; border-radius: 200px; top: 0; right:0; left: 40%; bottom: 0; } .box-right { display: block; position: absolute; background-color: blue; width: 8px; height: 100%; border-radius: 200px; top: 0; right:0; bottom: 0; } .box-bottom { display: block; position: absolute; background-color: blue; height: 8px; border-radius: 200px; right:0; left: 60%; bottom: 0; } <div class="box"> <div class="box-top"></div> <div class="box-right"></div> <div class="box-bottom"></div> </div> You can style as much as you like this is just to give to a rough idea how you might approach this. And there can be more than 1 ways to do it. Like I can see your outline is not inside the box but a few pixels out of it, and you can do that by tweaking the position values.
You can achieve that effect using some before or after pseudo elements. I've given a simple way to do that below. .box { height: 150px; width: 150px; background-color: red; border-radius: 8px; position: relative; overflow: hidden; } .box::before, .box::after { content: ''; display: block; position: absolute; background-color: transparent; pointer-events: none; } .box::before { top: 0; right:0; left: 40%; bottom: 0; border-top: 8px solid blue; border-right: 8px solid blue; } .box::after { top: 0; right:0; left: 60%; bottom: 0; border-bottom: 8px solid blue; } <div class="box"></div>
<svg viewBox="0 0 500 500"> <style> #curve { fill:#0004; box-shadow:0 0 0 8px #0004; } .border{ letter-spacing:-5px; fill:crimson; } </style> <path id="curve" fill="transparent" d="m100 50,h50,a25 25 0 0 1 25 25,v100,a25 25 0 0 1 -25 25,h-100,a25 25 0 0 1 -25 -25,v-100,a25 25 0 0 1 25 -25" /> <text width="500"> <textPath xlink:href="#curve" class="border"> •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• </textPath> </text> </svg> This isn't possible with only html and css. If you'd make the border with box-shadow: inset 0 0 0 5px, you could use another element on top of it with a conic-gradient with hard color stops to hide the unwanted parts of the box-shadow. The percentage for the color-stops determines how much is shown. The rounded corners on the line aren't possible like this.
Everything has positions etc... Why isn't Z-index working for me? [duplicate]
This question already has answers here: Why can't an element with a z-index value cover its child? (5 answers) Closed 3 years ago. just need someone to brief over my code and see if I've missed something because I can't seem to get z-index working now. I need the two containers that are animated to sit behind the portrait. I've been over all my z-index parameters and everything has a position so I'm not sure why it isn't layering properly. .positive { color: rgb(114, 204, 114); } .negative { color: rgb(224, 50, 50); } .tempbg { background: linear-gradient(#e66465, #9198e5); background-repeat: no-repeat; background-size: 1920px 1080px; } .masscont { background-color: rgba(0, 0, 0, 0); position: sticky; top: 50px; left: 1725px; width: 260px; height: 85px; z-index: 1; } .portrait { background-image: url("https://gdurl.com/VKq8"); position: fixed; top: 34px; left: 250px; width: 120px; height: 120px; border-radius: 110px; z-index: 5; display: block; opacity: 1; } .container { background-color: rgba(0, 0, 0, .237); position: absolute; top: 0px; left: 96px; width: 0px; height: 85px; border-radius: 50px; border-bottom-left-radius: 0%; border-top-left-radius: 0%; z-index: 1; opacity: 1; display: block; transition: width 2.2s cubic-bezier(0.24, 0.26, 0.63, 0.93); } .container:hover { width: 260px; } /*#heal, #armor, #hunger, #thirst, #stamina, #voice { }*/ #boxHeal, #boxArmor, #boxStamina, #boxHunger, #boxThirst, #boxVoice { width: 100%; height: 100%; transition: 0.2s ease-in-out; } #heal { position: absolute; left: 26px; bottom: 70px; width: 0px; height: 10px; padding: 0; float:left; transition: width 1.6s ease-in-out; } .container:hover #heal{ width: 140px; } .container:hover #armor{ width: 140px; } #armor { position: absolute; left: 27px; bottom: 54px; width: 0px; height: 10px; transition: width 1.6s ease-in-out; } #hunger { position: absolute; left: 62px; bottom: 28px; width: 0px; height: 10px; transition: width 1.5s ease-in-out; } .container:hover #hunger{ width: 113px; } .iconhunger { position: relative; left: -40px; bottom: 10px; z-index: 2; align-content: left; } #thirst { position: absolute; left: 22px; bottom: 54px; width: 0px; height: 10px; padding: 0; float:left; transition: width 1.5s ease-in-out; } .container:hover #thirst{ width: 113px; } .iconthirst { position: relative; left: 0.5px; bottom: -29.5px; z-index: 2; align-content: left; } #stamina { position: absolute; left: 62.5px; bottom: 1px; width: 0px; height: 10px; padding: 0; float:left; transition: width 1.5s ease-in-out; } .container:hover #stamina{ width: 113px; } .iconstamina { position: absolute; z-index: 2; align-content: left; left: -36px; bottom: -3px; } #voice { position: absolute; left: 200px; bottom: -00px; width: 107.5px; height: 10px; padding: 0; float:left; } .fa-microphone { position: absolute; z-index: 3; left: 69px; bottom: 25px; color: #525151; font-size: 38px; } .fa-microphonebg { position: absolute; top: -75px; left: -90px; width: 121px; height: 85px; background-image: radial-gradient(circle at 0% 50%, rgba(0,0,0,0) 50px, #fff 51px); border-top-right-radius: 40px; border-bottom-right-radius: 40px; z-index: 2; transition: left 1.7s ease-in-out; } .masscont:hover #fa-microphonebg { left: 80px; } #boxHeal { background: rgba(97, 191, 92, 1); border: solid 0.3px rgb(97, 191, 92); border-radius: 30px; } #boxArmor { background: rgb(96, 136, 220); border: solid 0.3px rgb(96, 136, 220); border-radius: 180px; border: -5px; } #boxHunger { background: rgb(255, 255, 255); position: absolute; left: -10px; bottom: 7px; border: solid 0.3px #ffffff; border-radius: 30px; } #boxThirst { background:rgb(255, 255, 255); position: absolute; left: 30px; bottom: -34px; border: solid 0.3px #ffffff; border-radius: 30px; } #boxStamina { background: rgb(255, 255, 255); position: absolute; left: -10px; bottom: 4px; border: solid 0.3px #ffffff; border-radius: 30px; } #boxVoice { background: rgb(180, 180, 180); position: absolute; z-index: 4; height: 27px; width: 14.2px; left: 6.2px; bottom: 11px; border-radius: 30px; } #boxVoice.active { background: rgb(46, 196, 66); } .position { font-family: "gta-ui", Verdana, Tahoma; font-size: 30px; position: absolute; bottom: 0.35%; left: 16%; text-shadow: -1px 1px 2px #000, 1px 1px 2px #000, 1px -1px 0 #000, -1px -1px 0 #000; color: #ffffff; } .seperator { color: rgb(224, 50, 50); } .seperator2 { color: rgb(240, 200, 80); } .walletcont { background-color: rgba(0, 0, 0, 0.288); position: absolute; z-index: 1; top: 15px; right: 105px; width: 0px; height: 85px; border-radius: 50px; border-bottom-right-radius: 0%; border-top-right-radius: 0%; transition: width 1.28s cubic-bezier(0.36, 0.28, 0.79, 0.94) 0.1s; } .walletcont:hover{ width: 260px; } .fa-wallet { position: absolute; z-index: 3; left: 20px; bottom: 25px; color: #525151; font-size: 38px; } .walletbg { position: absolute; top: 0px; right: -30px; width: 121px; height: 85px; background-image: radial-gradient(circle at 100% 50%, rgba(0,0,0,0) 50px, #fff 51px); border-top-left-radius: 40px; border-bottom-left-radius: 40px; z-index: 2; transition: right 1.5s ease-in-out; } .walletcont:hover #walletbackg { right: 140px; } .fa-pound-sign { position: absolute; z-index: 2; right: 0px; bottom: 60px; color: #ffffff; font-size: 18px; transition: right 1.5s ease-in-out; } .walletcont:hover #cash { right: 152.5px; } .fa-piggy-bank { position: absolute; z-index: 2; right: 0px; bottom: 35px; color: #ffffff; font-size: 16px; transition: right 1.5s ease-in-out; } .walletcont:hover #bank { right: 150px; } .blackmoneyic { position: absolute; right: 0px; bottom: 7px; transition: right 1.5s ease-in-out; z-index: 2; } .walletcont:hover #illegalcash { right: 150px; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <link href="css/style.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" href="https://icono-49d6.kxcdn.com/icono.min.css"> <script src="https://kit.fontawesome.com/3f31cfc768.js"></script> </head> <body class="tempbg"> <div class="portrait"> <div class="walletcont"> <div class="cash"><i id="cash" class="fas fa-pound-sign"></i></div> <div class="pigBank"><i id="bank" class="fas fa-piggy-bank"></i></div> <div class="illcash"><svg class="blackmoneyic" id="illegalcash" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 59.997 59.997" style="fill:#ffffff" xml:space="preserve" width="18px" height="18px"><g><g> <path d="M49.031,32.997c-0.669,0-1.338,0.04-1.998,0.111c-1.362-2.82-3.366-5.301-5.864-7.214l-7.202-4.894 c-1.191-0.914-3.068-2.002-5.246-2.002h-7.777c-1.924,0-3.816,0.655-5.3,1.822l-7.078,5.156c-7.377,5.8-9.712,15.964-5.551,24.168 c2.002,3.947,4.666,6.227,7.501,6.418c0.271,0.018,0.545,0.028,0.821,0.028h19.154c1.449,2.057,3.838,3.407,6.54,3.407 c1.409,0,2.731-0.369,3.882-1.011c1.739,0.633,4.76,1.011,8.118,1.011c9.271,0,9.998-2.22,10-2.903v-4v-0.001v-3.999v-0.001v-3.999 v-0.001v-3.999v-0.001v-4C59.031,35.064,53.984,32.997,49.031,32.997z M22.031,27.997c-5.271,0-12,7.29-12,13c0,0.552-0.448,1-1,1 s-1-0.448-1-1c0-6.869,7.589-15,14-15c0.552,0,1,0.448,1,1S22.583,27.997,22.031,27.997z M57.031,39.006v1.854 c-0.078,0.051-0.191,0.107-0.33,0.165c-0.008,0.003-0.014,0.006-0.022,0.009c-0.138,0.056-0.307,0.114-0.5,0.172 c-0.019,0.006-0.036,0.011-0.055,0.017c-0.193,0.057-0.415,0.114-0.659,0.17c-0.032,0.007-0.063,0.015-0.095,0.022 c-0.247,0.055-0.519,0.109-0.814,0.16c-0.042,0.007-0.086,0.015-0.129,0.022c-0.301,0.051-0.626,0.098-0.974,0.142 c-0.048,0.006-0.098,0.012-0.146,0.018c-0.358,0.043-0.738,0.082-1.143,0.116c-0.048,0.004-0.099,0.007-0.148,0.011 c-0.42,0.033-0.86,0.06-1.327,0.079c-0.036,0.001-0.074,0.002-0.11,0.003c-0.491,0.018-1.004,0.03-1.546,0.03 c-4.55,0-7.353-0.711-8-1.137v-1.368c1.106,0.092,2.271,0.183,3.378,0.262c1.24,0.15,2.75,0.244,4.622,0.244 c0.552,0,1.069-0.009,1.562-0.024c0.163-0.005,0.309-0.014,0.465-0.02c0.318-0.013,0.632-0.027,0.925-0.046 c0.172-0.011,0.331-0.025,0.495-0.038c0.253-0.02,0.503-0.041,0.737-0.065c0.16-0.017,0.312-0.035,0.463-0.054 c0.214-0.026,0.422-0.053,0.619-0.083c0.142-0.021,0.28-0.043,0.414-0.066c0.186-0.032,0.362-0.065,0.532-0.099 c0.12-0.024,0.24-0.049,0.353-0.075c0.164-0.037,0.316-0.077,0.465-0.116c0.098-0.026,0.199-0.052,0.291-0.079 c0.148-0.044,0.282-0.089,0.415-0.135c0.073-0.026,0.153-0.05,0.222-0.076C57.003,39.015,57.019,39.011,57.031,39.006z M50.592,43.973c0.164-0.005,0.31-0.014,0.468-0.02c0.317-0.013,0.632-0.027,0.924-0.046c0.171-0.011,0.328-0.025,0.49-0.038 c0.255-0.02,0.507-0.041,0.743-0.066c0.158-0.016,0.307-0.035,0.456-0.053c0.216-0.026,0.427-0.054,0.626-0.084 c0.139-0.021,0.274-0.042,0.406-0.065c0.189-0.032,0.369-0.066,0.542-0.101c0.117-0.024,0.233-0.047,0.343-0.072 c0.169-0.038,0.325-0.079,0.478-0.12c0.094-0.025,0.191-0.05,0.279-0.076c0.155-0.046,0.296-0.094,0.434-0.142 c0.067-0.023,0.14-0.046,0.203-0.07c0.015-0.006,0.033-0.011,0.048-0.016v1.854c-0.078,0.051-0.191,0.107-0.33,0.165 c-0.008,0.003-0.014,0.006-0.022,0.009c-0.138,0.056-0.307,0.114-0.5,0.172c-0.019,0.006-0.036,0.011-0.055,0.017 c-0.193,0.057-0.415,0.114-0.659,0.17c-0.032,0.007-0.063,0.015-0.095,0.022c-0.247,0.055-0.519,0.109-0.814,0.16 c-0.042,0.007-0.086,0.015-0.129,0.022c-0.301,0.051-0.626,0.098-0.974,0.142c-0.048,0.006-0.098,0.012-0.146,0.018 c-0.358,0.043-0.738,0.082-1.143,0.116c-0.048,0.004-0.099,0.007-0.148,0.011c-0.42,0.033-0.86,0.06-1.327,0.079 c-0.036,0.001-0.074,0.002-0.11,0.003c-0.491,0.018-1.004,0.03-1.546,0.03c-4.55,0-7.353-0.711-8-1.137v-1.362 c1.297,0.107,2.67,0.211,3.933,0.297c1.265,0.132,2.646,0.202,4.067,0.202C49.583,43.997,50.099,43.988,50.592,43.973z M50.592,47.973c0.164-0.005,0.31-0.014,0.468-0.02c0.317-0.013,0.632-0.027,0.924-0.046c0.171-0.011,0.328-0.025,0.49-0.038 c0.255-0.02,0.507-0.041,0.743-0.066c0.158-0.016,0.307-0.035,0.456-0.053c0.216-0.026,0.427-0.054,0.626-0.084 c0.139-0.021,0.274-0.042,0.406-0.065c0.189-0.032,0.369-0.066,0.542-0.101c0.117-0.024,0.233-0.047,0.343-0.072 c0.169-0.038,0.325-0.079,0.478-0.12c0.094-0.025,0.191-0.05,0.279-0.076c0.155-0.046,0.296-0.094,0.434-0.142 c0.067-0.023,0.14-0.046,0.203-0.07c0.015-0.006,0.033-0.011,0.048-0.016v1.854c-0.078,0.051-0.191,0.107-0.33,0.165 c-0.008,0.003-0.014,0.006-0.022,0.009c-0.138,0.056-0.307,0.114-0.5,0.172c-0.019,0.006-0.036,0.011-0.055,0.017 c-0.193,0.057-0.415,0.114-0.659,0.17c-0.032,0.007-0.063,0.015-0.095,0.022c-0.247,0.055-0.519,0.109-0.814,0.16 c-0.042,0.007-0.086,0.015-0.129,0.022c-0.301,0.051-0.626,0.098-0.974,0.142c-0.048,0.006-0.098,0.012-0.146,0.018 c-0.358,0.043-0.738,0.082-1.143,0.116c-0.048,0.004-0.099,0.007-0.148,0.011c-0.42,0.033-0.86,0.06-1.327,0.079 c-0.036,0.001-0.074,0.002-0.11,0.003c-0.491,0.018-1.004,0.03-1.546,0.03c-0.431,0-0.856-0.008-1.276-0.021 c-0.133-0.004-0.263-0.012-0.395-0.017c-0.284-0.012-0.567-0.025-0.843-0.042c-0.15-0.01-0.297-0.022-0.444-0.033 c-0.252-0.019-0.501-0.04-0.744-0.065c-0.148-0.015-0.293-0.031-0.437-0.047c-0.064-0.007-0.125-0.016-0.188-0.024 c-0.219-0.746-0.544-1.446-0.958-2.085c1.348,0.203,3.063,0.334,5.286,0.334C49.583,47.997,50.099,47.988,50.592,47.973z M50.592,51.973c0.164-0.005,0.31-0.014,0.468-0.02c0.317-0.013,0.632-0.027,0.924-0.046c0.171-0.011,0.328-0.025,0.49-0.038 c0.255-0.02,0.507-0.041,0.743-0.066c0.158-0.016,0.307-0.035,0.456-0.053c0.216-0.026,0.427-0.054,0.626-0.084 c0.139-0.021,0.274-0.042,0.406-0.065c0.189-0.032,0.369-0.066,0.542-0.101c0.117-0.024,0.233-0.047,0.343-0.072 c0.169-0.038,0.325-0.079,0.478-0.12c0.094-0.025,0.191-0.05,0.279-0.076c0.155-0.046,0.296-0.094,0.434-0.142 c0.067-0.023,0.14-0.046,0.203-0.07c0.015-0.006,0.033-0.011,0.048-0.016v1.854c-0.078,0.051-0.191,0.107-0.33,0.165 c-0.008,0.003-0.014,0.006-0.022,0.009c-0.138,0.056-0.307,0.114-0.5,0.172c-0.019,0.006-0.036,0.011-0.055,0.017 c-0.193,0.057-0.415,0.114-0.659,0.17c-0.032,0.007-0.063,0.015-0.095,0.022c-0.247,0.055-0.519,0.109-0.814,0.16 c-0.042,0.007-0.086,0.015-0.129,0.022c-0.301,0.051-0.626,0.098-0.974,0.142c-0.048,0.006-0.098,0.012-0.146,0.018 c-0.358,0.043-0.738,0.082-1.143,0.116c-0.048,0.004-0.099,0.007-0.148,0.011c-0.42,0.033-0.86,0.06-1.327,0.079 c-0.036,0.001-0.074,0.002-0.11,0.003c-0.491,0.018-1.004,0.03-1.546,0.03c-0.648,0-1.279-0.02-1.898-0.049 c-0.145-0.007-0.289-0.014-0.432-0.022c-0.602-0.035-1.191-0.081-1.746-0.143c-0.015-0.002-0.028-0.004-0.043-0.006 c0.08-0.454,0.12-0.913,0.12-1.372c0-0.075-0.007-0.151-0.009-0.227c0.001-0.061,0.009-0.12,0.009-0.181 c0-0.066-0.008-0.13-0.01-0.196c0.815,0.084,1.687,0.131,2.577,0.161c0.406,0.022,0.861,0.035,1.433,0.035 C49.583,51.997,50.099,51.988,50.592,51.973z M56.771,36.994c-0.011,0.005-0.023,0.01-0.035,0.015 c-0.111,0.048-0.24,0.097-0.393,0.147c-0.016,0.005-0.034,0.01-0.05,0.015c-0.155,0.049-0.329,0.099-0.523,0.149 c-0.02,0.005-0.037,0.01-0.057,0.015c-0.202,0.051-0.427,0.1-0.669,0.149c-0.043,0.009-0.086,0.017-0.13,0.026 c-0.247,0.048-0.512,0.094-0.798,0.138c-0.04,0.006-0.083,0.012-0.124,0.018c-0.29,0.043-0.596,0.083-0.923,0.12 c-0.02,0.002-0.039,0.005-0.059,0.007c-0.333,0.037-0.691,0.068-1.061,0.096c-0.068,0.005-0.136,0.01-0.205,0.015 c-0.369,0.026-0.755,0.047-1.158,0.062c-0.072,0.003-0.147,0.005-0.221,0.007c-0.428,0.014-0.869,0.023-1.333,0.023 s-0.905-0.009-1.333-0.023c-0.073-0.002-0.148-0.004-0.221-0.007c-0.403-0.015-0.789-0.036-1.158-0.062 c-0.069-0.005-0.137-0.01-0.205-0.015c-0.371-0.028-0.728-0.06-1.061-0.096c-0.02-0.002-0.039-0.005-0.059-0.007 c-0.327-0.037-0.633-0.077-0.923-0.12c-0.041-0.006-0.084-0.012-0.124-0.018c-0.286-0.044-0.551-0.09-0.798-0.138 c-0.044-0.009-0.087-0.017-0.13-0.026c-0.241-0.049-0.467-0.099-0.669-0.149c-0.02-0.005-0.038-0.01-0.057-0.015 c-0.194-0.05-0.369-0.1-0.523-0.149c-0.016-0.005-0.035-0.01-0.05-0.015c-0.153-0.05-0.281-0.099-0.393-0.147 c-0.012-0.005-0.023-0.01-0.035-0.015c0.927-0.705,3.775-1.997,7.74-1.997S55.844,36.289,56.771,36.994z M31.883,55.064 c-0.175-0.293-0.322-0.596-0.444-0.907c-0.008-0.022-0.016-0.044-0.024-0.066c-0.115-0.306-0.207-0.618-0.27-0.937 c-0.004-0.022-0.006-0.044-0.01-0.066c-0.055-0.295-0.085-0.595-0.094-0.897c-0.001-0.041-0.006-0.082-0.006-0.124 c-0.003-0.303,0.02-0.609,0.063-0.915c0.009-0.065,0.018-0.13,0.03-0.195c0.045-0.26,0.103-0.517,0.182-0.766 c0.008-0.027,0.02-0.052,0.029-0.078c0.084-0.251,0.185-0.496,0.302-0.733c0.011-0.023,0.022-0.046,0.033-0.068 c0.54-1.059,1.391-1.954,2.424-2.543c0.002-0.001,0.005-0.003,0.007-0.004c0.235-0.134,0.483-0.247,0.735-0.347 c0.062-0.024,0.125-0.046,0.188-0.069c0.228-0.082,0.461-0.152,0.7-0.205c0.026-0.006,0.051-0.014,0.077-0.02 c0.288-0.059,0.577-0.092,0.865-0.109c0.061-0.004,0.122-0.007,0.183-0.009c0.289-0.009,0.576-0.001,0.861,0.032 c0.027,0.003,0.053,0.009,0.081,0.012c0.295,0.038,0.587,0.096,0.875,0.179c0.009,0.003,0.018,0.004,0.027,0.007 c0.305,0.089,0.605,0.203,0.897,0.342c2.03,0.963,3.441,3.026,3.441,5.419c0,3.309-2.691,6-6,6 C34.844,57.997,32.932,56.817,31.883,55.064z M57.031,56.86c-0.648,0.427-3.452,1.137-8,1.137c-2.215,0-4.3-0.174-5.858-0.475 c0.457-0.546,0.838-1.151,1.135-1.802c0.09,0.011,0.187,0.019,0.279,0.03c0.149,0.018,0.301,0.033,0.453,0.049 c0.266,0.027,0.536,0.052,0.811,0.073c0.159,0.012,0.316,0.025,0.477,0.036c0.297,0.019,0.599,0.034,0.904,0.047 c0.143,0.006,0.284,0.014,0.429,0.019c0.451,0.014,0.907,0.023,1.37,0.023c0.551,0,1.068-0.009,1.561-0.024 c0.164-0.005,0.31-0.014,0.468-0.02c0.317-0.013,0.632-0.027,0.924-0.046c0.171-0.011,0.328-0.025,0.49-0.038 c0.255-0.02,0.507-0.041,0.743-0.066c0.158-0.016,0.307-0.035,0.456-0.053c0.216-0.026,0.427-0.054,0.626-0.084 c0.139-0.021,0.274-0.042,0.406-0.065c0.189-0.032,0.369-0.066,0.542-0.101c0.117-0.024,0.233-0.047,0.343-0.072 c0.169-0.038,0.325-0.079,0.478-0.12c0.094-0.025,0.191-0.05,0.279-0.076c0.155-0.046,0.296-0.094,0.434-0.142 c0.067-0.023,0.14-0.046,0.203-0.07c0.015-0.006,0.033-0.011,0.048-0.016V56.86z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#ffffff"/> <path d="M32.031,16.304v-2.307c0-0.552-0.448-1-1-1h-12c-0.552,0-1,0.448-1,1s0.448,1,1,1h11v1h-11c-0.552,0-1,0.448-1,1 s0.448,1,1,1h11.925c0.896,0.746,2,1.173,3.179,1.173c1.335,0,2.591-0.521,3.536-1.466c0.391-0.391,0.391-1.023,0-1.414 s-1.023-0.391-1.414,0C35.127,17.419,33.168,17.423,32.031,16.304z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#ffffff"/> <path d="M18.086,10.027c0.407,1.178,1.504,1.97,2.73,1.97h7.431c1.226,0,2.323-0.792,2.73-1.97 c0.388-1.126,1.607-3.645,2.553-4.445c0.829-0.703,1.218-1.792,1.014-2.842c-0.2-1.033-0.921-1.849-1.928-2.182 c-2.999-0.993-5.666-0.658-7.698,0.967c-0.357,0.287-0.86,0.287-1.22,0c-2.032-1.625-4.701-1.96-7.697-0.967 c-1.007,0.333-1.729,1.148-1.929,2.182c-0.204,1.05,0.185,2.139,1.014,2.842C16.156,6.489,17.796,9.187,18.086,10.027z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#ffffff"/> </g></g> </svg></div> <div class="walletbg" id="walletbackg"> <i class="fas fa-wallet"></i> </div> </div> <div class="masscont" id="masscont"> <div class="container"> <div id="heal"> <div id="boxHeal"></div> </div> <div id="armor"> <div id="boxArmor"></div> </div> <div id="hunger"> <svg class="iconhunger" width="36" height="12" viewBox="0 0 14 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#clip0)"> <path d="M9.44096 7.09788L12.0944 4.62314C13.9855 2.86906 14.0734 1.25095 13.9708 0.462298C13.9561 0.407908 13.9268 0.353518 13.8828 0.312725C13.7656 0.203945 13.5897 0.203945 13.4724 0.312725L12.6954 1.03339L2.94672 10.0893C2.62421 10.3885 2.62421 10.8916 2.94672 11.1907C3.26923 11.4899 3.81164 11.4899 4.13415 11.1907L4.33939 10.946C4.70588 10.4973 6.58232 7.98172 6.86086 7.58739C6.97813 7.42422 7.09541 7.32904 7.18337 7.28825C7.32997 7.23386 7.44724 7.30185 7.44724 7.30185C8.09227 7.65538 8.91321 7.58739 9.44096 7.09788Z" fill="white"/> <path d="M4.95508 6.20047C5.49749 5.9965 5.86398 6.17327 6.09854 6.36364L6.86084 5.65657C6.65561 5.43901 6.46503 5.08547 6.68493 4.59596C6.99278 3.90249 7.242 3.45377 6.17184 2.37957C5.131 1.29176 3.4598 0.285548 2.68283 0.0679876C2.50692 0.027195 2.331 0 2.19906 0C2.1844 0 2.1844 0 2.16974 0C2.12577 0 2.09645 0.0135975 2.06713 0.0407925C1.99383 0.10878 1.99383 0.21756 2.06713 0.27195L4.70587 2.7195C4.83781 2.84188 4.83781 3.04584 4.70587 3.18182C4.57393 3.3042 4.35404 3.3042 4.20744 3.18182L3.89959 2.89627L3.21058 2.25719C2.69749 1.78127 2.36032 1.46853 2.03781 1.22378C1.26084 0.625486 0.95299 0.611888 0.95299 0.611888C0.95299 0.611888 0.835713 0.598291 0.733095 0.679876C0.645137 0.775058 0.659797 0.883838 0.659797 0.883838C0.659797 0.883838 0.674456 1.16939 1.33414 1.90365C1.59802 2.2028 1.93519 2.51554 2.44828 2.99145L3.13728 3.63054L3.44514 3.91608C3.57707 4.03846 3.57707 4.24242 3.44514 4.3784C3.3132 4.50078 3.0933 4.50078 2.94671 4.3784L0.307964 1.93085C0.234666 1.86286 0.117388 1.86286 0.0587496 1.93085C0.0294302 1.95804 0.0147705 1.98524 0.0147705 2.02603C0.0147705 2.02603 0.0147705 2.03963 0.0147705 2.05322C0.0147705 2.1756 0.0440899 2.33877 0.0880689 2.50194C0.307964 3.22261 1.40744 4.75913 2.58022 5.75175C3.73833 6.71717 4.20744 6.48601 4.95508 6.20047Z" fill="white"/> <path d="M9.51434 7.737C9.1625 7.95456 8.73737 8.07694 8.29758 8.07694C8.03371 8.07694 7.78449 8.03614 7.53528 7.95456L10.6138 11.3539C11.0683 11.7619 11.7866 11.7619 12.2264 11.3539C12.6662 10.946 12.6662 10.2661 12.2264 9.85821L9.51434 7.737Z" fill="white"/> </g> </svg> <div id="boxHunger"> </div> </div> <div id="thirst"> <svg class="iconthirst" width="36" height="14" viewBox="0 0 8 12" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M3.74196 0.100677C3.72525 0.0356591 3.65843 -0.013104 3.57491 0.00315034C3.52479 0.0194047 3.49138 0.0519134 3.47467 0.100677C2.9067 4.55437 0 5.46462 0 8.5692C0.0501155 10.5035 1.68722 12.0476 3.67514 11.9989C5.61294 11.9664 7.16652 10.4385 7.19993 8.5692C7.21663 5.48087 4.30993 4.55437 3.74196 0.100677ZM3.19069 5.02575C3.15728 5.15579 3.10716 5.30207 3.07375 5.44836C2.82317 6.34235 2.52248 7.35013 2.52248 8.52044C2.52248 9.15436 2.13826 9.38192 1.77075 9.38192C1.35312 9.38192 1.01902 9.05683 1.01902 8.65048C1.01902 7.26885 1.70393 6.35861 2.30531 5.56215C2.48907 5.31833 2.67283 5.07451 2.82317 4.84695C2.88999 4.74943 3.00693 4.73317 3.10716 4.79819C3.12387 4.81444 3.14057 4.8307 3.15728 4.84695C3.19069 4.89572 3.20739 4.96073 3.19069 5.02575Z" fill="white"/> </svg> <div id="boxThirst"></div> </div> <div id="stamina"> <svg class="iconstamina" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="22px" height="22px" viewBox="0 0 487.811 487.81" style="enable-background:new 0 0 487.811 487.81;" xml:space="preserve"><g><g> <g id="_x33_6_24_"> <g> <path d="M150.463,109.521h150.512c3.955,0,7.16-3.206,7.16-7.161c0-3.955-3.205-7.161-7.16-7.161H150.463 c-3.955,0-7.161,3.206-7.161,7.161C143.302,106.315,146.508,109.521,150.463,109.521z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#FFFFFF"/> <path d="M15.853,179.537h150.511c3.955,0,7.161-3.206,7.161-7.161s-3.206-7.16-7.161-7.16H15.853 c-3.955,0-7.161,3.205-7.161,7.16S11.898,179.537,15.853,179.537z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#FFFFFF"/> <path d="M56.258,253.214c0,3.955,3.206,7.162,7.161,7.162H213.93c3.955,0,7.161-3.207,7.161-7.162s-3.206-7.16-7.161-7.16H63.419 C59.464,246.054,56.258,249.259,56.258,253.214z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#FFFFFF"/> <path d="M142.396,336.44H7.161C3.206,336.44,0,339.645,0,343.6s3.206,7.161,7.161,7.161h135.235c3.955,0,7.161-3.206,7.161-7.161 S146.351,336.44,142.396,336.44z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#FFFFFF"/> <path d="M385.729,154.418c21.6,0,39.111-17.513,39.111-39.114s-17.512-39.113-39.111-39.113 c-21.605,0-39.119,17.513-39.119,39.113C346.609,136.905,364.123,154.418,385.729,154.418z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#FFFFFF"/> <path d="M450.066,143.155c-22.459,31.459-52.533,35.102-84.895,15.89c-2.203-1.306-11.977-6.691-14.141-7.977 c-52.061-30.906-104.061-18.786-138.934,30.05c-14.819,20.771,19.455,40.459,34.108,19.93 c18.018-25.232,40.929-32.533,65.986-24.541c-12.83,22.27-24.047,44.405-39.875,75.853 c-15.832,31.448-50.787,56.562-84.374,36.92c-24.235-14.165-46.09,20.651-21.928,34.772 c45.854,26.799,99.619,10.343,127.066-24.493c0.952,0.509,1.958,0.968,3.062,1.354c22.422,7.812,51.814,28.61,60.77,35.981 c8.953,7.371,24.336,44.921,33.471,63.788c11.082,22.893,46.871,6.219,35.748-16.771c-10.355-21.406-27.736-64.129-41.293-74.938 c-10.875-8.669-31.988-24.803-49.895-33.956c12.115-23.466,24.729-46.679,38.008-69.491 c42.328,12.969,82.561-2.308,111.215-42.446C498.996,142.312,464.73,122.624,450.066,143.155z" data-original="#000000" class="active-path" data-old_color="#000000" fill="#FFFFFF"/> </g> </g> </g></g> </svg> <div id="boxStamina"></div> <div id="voice"> </div> <div class="fa-microphonebg" id="fa-microphonebg"> <i class="fas fa-microphone"><span id="boxVoice"></span></i> </div> </div> </div> </div> </div> <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"> </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"> </script> <script src="js/app.js"> </script> </body> </html>
The problem is that .walletcont and .masscont are inside .portrait, so their z-index don't affect .portrait as expected. They can't be behind or in front of each other if they are not siblings in this case.
How to make an up and down arrow
How can draw an up-down arrow with pure CSS? This is what I get using HTML : .up-down-arrow { font-size: 50px; color: #666; padding: 0; margin: 0; display: inline-block; } <div class="up-down-arrow">↕</div> But the line between the arrows is too short. Can I make it longer? Ideally, this is what I am after:
Single element solution You can achieve that with pseudo elements, CSS triangles and some positioning: .arrow { width: 2px; height: 200px; /* <- adjust your height as you need it */ background: black; margin: 10px; position: relative; } .arrow::before, .arrow::after { content: ''; position: absolute; left: -9px; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; } .arrow::before { top: 0; border-bottom: 15px solid black; } .arrow::after { bottom: 0; border-top: 15px solid black; } <div class="arrow"></div> Multiple elements solution To achieve the actual arrow shape, you will need multiple elements. Here the pseudo elements are used to create white triangles, that cut out the black arrow heads: .arrow { width: 2px; height: 200px; /* <- adjust your height as you need it */ background: black; margin: 10px; position: relative; } .up, .down, .arrow::before, .arrow::after { position: absolute; left: -9px; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; } .up { top: 0; border-bottom: 15px solid black; } .down { bottom: 0; border-top: 15px solid black; } .arrow::before, .arrow::after { content: ''; z-index: 2; } .arrow::before { top: 11px; border-bottom: 4px solid white; } .arrow::after { bottom: 11px; border-top: 4px solid white; } <div class="arrow"> <div class="up"></div> <div class="line"></div> <div class="down"></div> </div> Or another variant with a continuous line: .line { position: relative; margin: -15px 0 -15px 9px; width: 2px; height: 180px; background-color: black; z-index: 5; } .up, .down { position: relative; z-index: 3; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; } .up { border-bottom: 15px solid black; } .down { border-top: 15px solid black; } .down::before, .up::after { position: absolute; left: -10px; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; content: ''; z-index: 4; } .down::before { bottom: 11px; border-top: 4px solid white; } .up::after { top: 11px; border-bottom: 4px solid white; } <div class="arrow"> <div class="up"></div> <div class="line"></div> <div class="down"></div> </div>
To make the up-down arrows with the line in between the same as your example, I would suggest using SVG. You can use it inline as shown in the following example : .wrap{ position:relative; height:70vh; border-left:1px solid #000; margin:10vh 50px; padding:5vh 20px; } .arrow { position:absolute; left:-5px; width: 9px; height: auto; } .up{top:-9px;} .down{bottom:-9px;} <div class="wrap"> <svg class="arrow up" viewbox="0 0 7 10"> <path d="M3.5 0 L7 10 Q3.5 7 0 10z"/> </svg> <svg class="arrow down" viewbox="0 0 7 10"> <path d="M3.5 10 L7 0 Q3.5 3 0 0z"/> </svg> Whatever content you need here </div> The inline SVG arrows are made with a path element and using one quadratic curve (made with Q3.5 7 0 10 in the up arrow). The line between the arrows is made with a border left on a container div it expands with the height of this container. Both arrows are positioned absolutely.
Here is one more solution using arrow char code \027A4 for ::before and ::after content. Size of these chars has bound to root font size rem and their modification rotate, top and left based on the content font-size. .arrow { position: relative; width: 3px; height: 150px; margin: 20px; background: tomato; } .arrow::before, .arrow::after { content: '\027A4'; position: absolute; font-size: 1.5rem; color: tomato; } .arrow::before { top: -.9em; left: -.5em; transform: rotate(-90deg); } .arrow::after { bottom: -.9em; left: -.32em; transform: rotate(90deg); } <div class="arrow"></div>
To keep it simple, change the height style in mid class to increase the length of line! .up { width: 0px; height: 0px; border-bottom: 10px solid black; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: none; } .mid { margin-left:7px; width: 2px; height: 180px; background-color:black; } .down{ width: 0px; height: 0px; border-top: 10px solid black; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: none; } <div class='up'></div> <div class='mid'></div> <div class='down'></div> Hope it helps!
How can I add a shadow to this triangle
I have tried adding a shadow to my triangle but it just wont work, this is so annoying! Heres my code: function section_about() { $(".about").css("display", "inline-block"); $(".about").animate({opacity:"1"}, {duration: 1000, queue: false}); window.location.hash = "/About Us/"; } function triangle_sizer() { $(".triangle-up").css("border-left-width", jQuery(window).width()/2); $(".triangle-up").css("border-right-width", jQuery(window).width()/2); $(".triangle-up").css("top", jQuery(window).height()-125); $(".triangle-down").css("border-left-width", jQuery(window).width()/2); $(".triangle-down").css("border-right-width", jQuery(window).width()/2); $(".triangle-down").css("top", jQuery(window).height()-125); } triangle_sizer(); jQuery(window).resize(function() { triangle_sizer(); }); ##style.css## .triangle-down { width: 0; height: 0; border-style: solid; border-width: 100px 200px 0 100px; border-color: rgba(39, 39, 39, 1) transparent transparent transparent; box-shadow: 0 16px 10px -17px rgba(0, 0, 0, 0.5); } .triangle-down:after { content: ""; position: absolute; width: 0; height: 0; background: rgba(39, 39, 39, 1); -webkit-transform: rotate(45deg); box-shadow: -1px -1px 10px -2px rgba(0, 0, 0, 0.5); } .par { position: absolute; top: 200%; width: 100%; height: 0%; } /* Arrows */ .arrows { width: 220px; height: 144px; position: absolute; left: 50%; top: 70%; margin-left: -76.5px; } .arrows path { stroke: white; fill: transparent; stroke-width: 1px; } /* Arrows */ .arrows-down { width: 220px; height: 144px; position: absolute; left: 50%; top: 70%; margin-left: -78.5px; } .arrows-down path { stroke: white; fill: transparent; stroke-width: 1px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="par"> <div class="triangle-down"> <svg class="arrows-down" viewbox="0 0 102 102"> <path class="a1" d="M0 20 L30 52 L60 20"></path> </svg> </div> </div> I have been searching for a solution for a long time and cant find one. This is what happens when that code is ran: https://gyazo.com/c890a79c547f5624c97abacc66104fc1 https://jsfiddle.net/Lec8862y/2/
HTML <span class="triangle">▼</span> CSS span { display: inline-block; transform: scaleX(8.5); color: lightgreen; text-shadow: 0 2px 2px rgba(255,255,255,0.7), 0 10px 4px rgba(0,0,0,0.5); font-size: 92px; } span:hover { transition: all 0.2s ease; transform: scaleX(9.5) translateY(4px); text-shadow: 0 1px 1px rgba(0,0,0,0.5); } body { padding: 20px; margin-left: 260px; margin-top: -40px } Working Fiddle: https://jsfiddle.net/rittamdebnath/drefg8r4/
You can try using box-shadow to build a triangle instead of border. Then on :before or :after elements you can set an overlapping box-shadow, example by Chris Coyier: http://codepen.io/chriscoyier/pen/bNZWzK
You can cuplicate your element, align it directly behind the default triangle and use the css filter propertie in conjunction with absolute position and the back element size. .triangle-down { position: relative; width: 220px; height: 220px; box-sizing: border-box; } .arrows-down { display: block; height: auto; max-width: 200px; box-sizing: border-box; } .arrows-down-back { position: absolute; left: 0; top: 0; max-width: 200px; filter: blur(20px) opacity(.3); -webkit-filter: blur(20px) opacity(.3); } <div class="par"> <div class="triangle-down"> <svg class="arrows-down img-responsive" viewbox="0 0 102 102"> <path class="a1" d="M0 20 L30 52 L60 20"></path> </svg> <svg class="arrows-down img-responsive arrows-down-back" viewbox="0 0 102 102"> <path class="a1" d="M0 20 L30 52 L60 20"></path> </svg> </div> </div>
You could relay only on a gradient to draw and blur(shadow) the triangle. If you use vertical margin/padding in percentage, it takes the width for reference, so arrow is resized from width, not height of content. div { position:relative; color:white; background:#333; text-align:center; margin:1em; margin-bottom:5.5%; box-shadow: 0 0 5px #333; } div:after { content:''; display:block; position:absolute; top:100%; left:0; right:0; padding-top:5%; background:linear-gradient(to bottom left, #333 49%, transparent 51%) no-repeat 0 0, linear-gradient(to bottom right, #333 49%, transparent 51%) no-repeat top right; background-size:50% 99% } html {/* demo purpose to show arrow box is translucide */ background:linear-gradient(45deg, yellow,gray,purple,white,lime, yellow,gray,purple,white,lime); min-height:100%; } <div>responsive box arrow, resize me or add content </div> <div>i can be replicated <hr/> maybe you should use a <code>class</code> there </div>
How to inscribe the following shape with CSS inside div?
FIDDLE HTML <div id="DiamondCenter"> <div id="triangle-topleft"></div> </div> CSS #DiamondCenter { position:fixed; top:2%; left:48%; background: #24201a; height:40px; width:40px; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); z-index:20 !important; } #triangle-topleft { width: 0; height: 0; border-top: 40px solid gray; border-right: 40px solid transparent; }
Using SVG: While using SVG, you could make use of path and polyline elements to draw the required shape. As indicated by Paulie_D in comments, SVG is the better choice for such complex shapes instead of CSS (though this can be achieved with CSS also). The approach is very simple and is as follows: One path element for the top polygon which is drawn by joining the points at coordinates (0,50), (50,0), (100,50) and (50,70). Another path element for the bottom polygon which is drawn by joining the points at (0,50), (50,70) and (100,50). One polyline element for the orange border which is nothing but a line connecting (0,50), (50,70) and (100,50). svg { height: 100px; width: 100px; } path#top { fill: gray; } path#bottom { fill: black; } polyline#border { stroke: orange; stroke-width: 2; fill: none; } <svg viewBox="0 0 100 100"> <path id="top" d="M0,50 L50,0 100,50 50,70z" /> <path id="bottom" d="M0,50 L50,100 100,50 50,70z" /> <polyline id="border" points="0,50 50,70 100,50" /> </svg> Using CSS: You can achieve the shape provided in question by using 2 pseudo-elements which are both rotated and skewed. The dimension of each pseudo-element is calculated using Pythagoras theorem. The shape produced using this method is responsive and can adapt to changes in dimension. Hover the shape within the snippet to see how it adapts. *, *:after, *:before { box-sizing: border-box; } #DiamondCenter { position: fixed; top: 2%; left: 48%; background: #24201a; height: 40px; width: 40px; transform: rotate(45deg); z-index: 20 !important; overflow: hidden; } #DiamondCenter:after { position: absolute; content: ''; bottom: 0px; left: -1px; /* half the width of border-left */ height: calc(100% / 1.414); width: calc(100% / 1.414); background: black; border-left: 2px solid orange; transform: rotate(40deg) skewX(-20deg); transform-origin: bottom left; } #DiamondCenter:before { position: absolute; content: ''; top: -1px; /* half the width of border-top */ right: 0px; height: calc(100% / 1.414); width: calc(100% / 1.414); background: black; border-top: 2px solid orange; transform: rotate(-40deg) skewY(-20deg); transform-origin: top right; } /* Just for demo */ #DiamondCenter{ transition: all 1s; } #DiamondCenter:hover{ top: 5%; height: 80px; width: 80px; } <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> <div id="DiamondCenter"></div> In the below snippet, I have set different background colors for the pseudo-elements to illustrate how the shape is achieved. *, *:after, *:before { box-sizing: border-box; } #DiamondCenter { position: fixed; top: 2%; left: 48%; background: #24201a; height: 40px; width: 40px; transform: rotate(45deg); z-index: 20 !important; overflow: hidden; } #DiamondCenter:after { position: absolute; content: ''; bottom: 0px; left: -1px; height: calc(100% / 1.414); width: calc(100% / 1.414); background: seagreen; border-left: 2px solid orange; transform: rotate(40deg) skewX(-20deg); transform-origin: bottom left; } #DiamondCenter:before { position: absolute; content: ''; top: -1px; right: 0px; height: calc(100% / 1.414); width: calc(100% / 1.414); background: skyblue; border-top: 2px solid orange; transform: rotate(-40deg) skewY(-20deg); transform-origin: top right; } /* Just for demo */ #DiamondCenter{ transition: all 1s; } #DiamondCenter:hover{ top: 5%; height: 80px; width: 80px; } <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> <div id="DiamondCenter"></div>
This is quite a complicated shape to complete in CSS, but as shown by others it is possible. A good alternative though would be to use SVG. Its a vector graphic so it scales brilliantly for responsiveness and is very well supported (CanIUse) <svg width="50%" height="50%" viewBox="0 0 10 10"> <path d="M5,1 L9,5 L5,9 L1,5z" fill="grey" /> <path d="M1,5 L5,6 L9,5 L5,9z" stroke="orange" stroke-width=".1" stroke-dasharray="0,0,8.23,15" /> </svg>
You can create diamond shape using this css , suppose this is div where you want above shape id should be same as css (cut-diamond) #cut-diamond { border-style: solid; border-color: transparent transparent red transparent; border-width: 0 25px 25px 25px; height: 0; width: 50px; position: relative; margin: 20px 0 50px 0; } #cut-diamond:after { content: ""; position: absolute; top: 25px; left: -25px; width: 0; height: 0; border-style: solid; border-color: red transparent transparent transparent; border-width: 70px 50px 0 50px; } JSFiddle Demo