so i have the following design for some "button tabs".
One side is curved, so border radius would not really be possible.
But is this type of curve even possible ?
or am i doomed to use some sort of image?
mostly looking for tips on how this might be accomplished, or somewhere i can look for a solution, since my previous tries to find a solution has yet to yield a result.
Html
<div class="tab-row">
<button>All Products<div class="tab-row__counter">20</div></button>
<button>Hardware<div class="tab-row__counter">20</div></button>
<button>Virtual<div class="tab-row__counter">20</div></button>
<button>Bundles<div class="tab-row__counter">20</div></button>
</div>
Css
.tab-row{
button{
background-color:$element-bg;
border:0;
color:$white;
width:300px;
height:90px;
margin-right:20px;
margin-top:40px;
border-radius: 5px 100px 0 0;
&:first-child{
margin-left:40px;
}
.tab-row__counter{
}
}
}
This is what i ended up with as a result,
https://codepen.io/andrelange91/pen/YzPqJXO
not exactly curved but close enough
You can try the curves by using the border-radius, transform, and transform-origin properties like,
/**
* Slanted tabs with CSS 3D transforms
* See http://lea.verou.me/2013/10/slanted-tabs-with-css-3d-transforms/
*/
body { padding: 50px;background:#20273d }
nav {
position: relative;
z-index: 1;
white-space: nowrap;
}
nav a {
position: relative;
display: inline-block;
padding: 1.5em 2em 1em 1em;
color:#9a9a9a;
text-decoration: none;
margin: 0 -7px;
}
nav a::before {
content: ''; /* To generate the box */
position: absolute;
top: 0; right: 0; bottom: .5em; left: 0;
z-index: -1;
border-radius: 10px 10px 0 0;
background: #434f78;
box-shadow: 0 2px hsla(0,0%,100%,.5) inset;
transform: perspective(5px) rotateX(2deg);
transform-origin: bottom left;
}
nav a.selected {
z-index: 2;
color:#FFF;
}
<nav class="left">
All Products
Hardware
Virtual
</nav>
You can use radial gradient also,
body { padding: 50px;background:#20273d }
nav {
position: relative;
z-index: 1;
white-space: nowrap;
}
nav a {
position: relative;
display: inline-block;
padding: 1em 5em 1.2em 1em;
color:#9a9a9a;
text-decoration: none;
margin: 0 -20px;
border: 0px none;
}
nav a::before {
content: ''; /* To generate the box */
position: absolute;
top: 0;
right: 0;
bottom: .5em;
left: 0;
z-index: -1;
background: radial-gradient(circle at top right,transparent 5.8vw, #434f78 6.8vw);
transform: perspective(10px) rotateX(1deg);
transform-origin: bottom left;
border: 0px none;
}
nav a.selected {
z-index: 2;
color:#FFF;
}
<nav class="left">
All Products
Hardware
Virtual
</nav>
Whilst this does not replicate the exact shape you're after, this does provide an example of the method I described in the comments in how to approach it. You will just need to edit the values in ::before and ::after to get it to your desired shape.
.curve {
background: blue;
width: 50px;
height: 75px;
position: relative;
}
.curve:before {
content: '';
background-image: radial-gradient(circle at 100% 100%, rgba(204, 0, 0, 0) 100px, blue 100px);
position: absolute;
top: 0;
left: 100%;
width: 100px;
height: 75px;
}
.curve:after {
content: '';
position: absolute;
width: 50px;
height: 75px;
background: blue;
border-radius: 0 0 100% 0 / 0 0 100% 0;
top: 100%;
left: 0;
}
.container {
display: flex;
align-items: flex-start;
justify-content: center;
}
.tab {
height: 150px;
width: 300px;
background: red
}
<div class="container">
<div class="tab"></div>
<div class="curve"></div>
</div>
Also take a look at Creating s-shaped curve using css
I'm trying to get this result :
And here is what I have for now (I'm only trying to get the result on the left element for the moment) :
I am trying to have this left arrow transparent but I can't find how to do that.
CSS Code :
.main_container .photo_container .mask a {
color: #FFFFFF;
font-size: 25px;
position: relative;
}
.main_container .photo_container .mask a:first-child {
border: 1px solid #FFFFFF;
padding: 5px 11px 7px;
}
.main_container .photo_container .mask a:first-child::before {
border-bottom: 7px solid transparent;
border-right: 7px solid rgba(0, 0, 0, 0.2);
border-top: 7px solid transparent;
content: "";
display: inline-block;
left: -8px;
position: absolute;
top: 20px;
}
.main_container .photo_container .mask a:first-child::after {
border-bottom: 24px solid transparent;
border-right: 25px solid #eee;
border-top: 24px solid transparent;
content: "";
display: inline-block;
left: -26px;
position: absolute;
top: -1px;
}
HTML Code :
<div class="photo_container">
<img src="images/placeholder/car1.png" class="img-responsive" alt="" />
<div class="mask">
<i class="fa fa-search"></i>
<i class="fa fa-link"></i>
</div>
</div>
Can you help me?
If you don't mind using transform this is pretty simple:
Making a pseudo element after the existing one, centering it on the correct side, and rotating it by 45 degrees.
The 70.71% figure is gotten using s = q / sqrt(2) where s is the side of a square, and q is the diagonal.
.arrow
{
border: 1px white;
border-style: solid solid solid none;
position: relative;
width: 50px;
height: 50px;
}
.arrow::after
{
content: "";
display: block;
top: 50%;
left: 0;
position: absolute;
border: 1px white;
border-style: none none solid solid;
width: 70.71%; /* the side of a square is 70.71% the length of it's diagonal */
height: 70.71%;
transform: translate(-50%, -50%) rotate(45deg);
}
Finally, we can change what borders are shown, and the absolute positioning to make the arrow appear on the desired side:
body
{
background-color: black;
padding: 50px;
}
.arrow_left,
.arrow_right
{
display: inline-block; /* just to get them next to eachother */
border: 1px white;
position: relative;
width: 50px;
height: 50px;
}
.arrow_left { border-style: solid solid solid none; }
.arrow_right { border-style: solid none solid solid; }
.arrow_left::after,
.arrow_right::after
{
content: "";
display: block;
top: 50%;
position: absolute;
border: 1px white;
width: 70.71%; /* the side of a square is 70.71% the length of it's diagonal */
height: 70.71%;
transform: translate(-50%, -50%) rotate(45deg);
}
.arrow_left::after
{
left: 0;
border-style: none none solid solid;
}
.arrow_right::after
{
left: 100%;
border-style: solid solid none none;
}
<div class="arrow_left"></div>
<div class="arrow_right"></div>
The left 'arrow' cannot be transparent, because in reality it is just a solid border applied to 1/4 of a box.
(See this article explaining how the css triangle effect is achieved.)
You will either need to use images, or tweak the graphic design.
You tried use border to achieve transparent triangle. It doesn't work. So let's think about other way to implement what we want.
I created simple demo - any triangle is made by 2 lines (simple trigonometry knowledge needed.)
http://codepen.io/anon/pen/PPbxEQ - i used some variables in css, so in that case i used stylus - more prefer read the source code, not just compiled result.
We create a pseudo element for first icon. Rotate it and evaluate new height. Than change transform-origin. Easy.
We change the angle - and recalculate the cos(angle);
*,
*:before,
*:after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
background-image: url("http://7-themes.com/data_images/out/2/6775415-beautiful-images.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: 0 0;
overflow: hidden;
}
html,
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
.Icons {
width: 50vmin;
height: 25vmin;
display: flex;
}
.Icon {
flex: 1;
border-color: currentColor;
border-style: solid;
display: flex;
align-items: center;
justify-content: center;
font-size: calc(2vw + 2vh + 4vmin);
color: #fff;
position: relative;
}
.Icon + .Icon {
margin-left: -1px;
}
.Icon:first-of-type {
border-width: 1px 1px 1px 0;
}
.Icon:last-of-type {
border-width: 1px 0 1px 1px;
}
.Icon:first-of-type:before,
.Icon:first-of-type:after,
.Icon:last-of-type:before,
.Icon:last-of-type:after {
content: '';
position: absolute;
margin: auto;
color: inherit;
background-color: currentColor;
width: 1px;
height: calc(50% / 0.866025404); /* Our angle is 30deg, so formula is calc(50% / cos(angle)) */
}
.Icon:first-of-type:before,
.Icon:first-of-type:after {
left: 0;
}
.Icon:first-of-type:before {
top: 0;
transform: rotateZ(30deg);
transform-origin: top;
}
.Icon:first-of-type:after {
bottom: 0;
transform: rotateZ(-30deg);
transform-origin: bottom;
}
.Icon:last-of-type:before,
.Icon:last-of-type:after {
right: 0;
}
.Icon:last-of-type:before {
top: 0;
transform: rotateZ(-30deg);
transform-origin: top;
}
.Icon:last-of-type:after {
bottom: 0;
transform: rotateZ(30deg);
transform-origin: bottom;
}
<div class="Icons">
<div class="Icon">I</div>
<div class="Icon">O</div>
</div>
I'm trying to make the div for bootstrap to look like below not sure how you do it with css. The arrow and the section labeleled movies
Please view the pic at https://plus.google.com/+SamuelMuiruri/posts/fMMhNQwPbCm
First of all you have to position the title "Movies" about the description. The arrow is a only a little css magic
HTML:
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="specialbox">
<img src="https://placeimg.com/320/240/tech"/>
<div class="specialbox__description">
<span class="specialbox__title">Movies</span>
<h2>Age of Ultron</h2>
<p>Tony Stark tries ti jumpstart a dormant peace-kepping program...</p>
</div>
</div>
</div>
</div>
</div>
CSS:
.specialbox {
border: 3px solid #ccc;
}
.specialbox img {
width: 100%;
}
.specialbox__description {
position: relative; /* You need this, to position the title element absolute to the description */
padding: 20px 10px;
}
.specialbox__title {
position: absolute;
background-color: yellow;
text-transform: uppercase;
padding: 10px;
border-radius: 10px 10px 0 0;
top: -40px; /* Adjust to the height of the title container */
}
/* Magic described here */
.specialbox__title:after {
position: absolute;
display: block;
content: '';
width: 30px;
height: 30px;
border: 15px solid transparent;
left: 50%;
bottom: -30px;
margin-left: -15px;
border-top: 15px solid yellow;
}
http://jsfiddle.net/ytbtbt1d/
I think you want to create a TRIANGLE edge below the div containg the text -'MOVIES' (see screenshot below)
I have created a code for you here: JSFIDDLE
HTML:
<div>Movies</div>
CSS
div{
position: relative;
display:inline-block;
width: 140px;
padding: 10px;
background:#FFC000;
text-transform: uppercase;
font-size: 24px;
text-align: center;
}
div:after{
position: absolute;
width: 0;
height: 0;
border-bottom: 40px solid rgba(0, 0, 0, 0);
border-right: 40px solid #FFC000;
bottom: -15px;
left: 0;
right:0;
margin:auto;
content: '';
-ms-transform: rotate(135deg); /* IE 9 */
-webkit-transform: rotate(135deg); /* Chrome, Safari, Opera */
transform: rotate(135deg);
}
I'm trying to rotate a simple navigation, and have it positioned to the left of the container div. However, I'm not sure how the rotate is supposed to work. For some reason, the div is not overlapping its parent and is out of site.
My desired outcome looks like this, with the text aligned to the left of the container:
http://jsfiddle.net/ges7L/
.write-note-container {
position: fixed;
height: 400px;
width: 800px;
border: 2px solid #000;
top: 50%;
margin-top: -200px;
right: 0;
background-color: orange;
}
.write-note-container .nav {
background-color: blue;
height: 400px;
border: 1px solid pink;
}
.write-note-container .nav .rotate {
-ms-transform:rotate(90deg); /* IE 9 */
-moz-transform:rotate(90deg); /* Firefox */
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
background-color: red;
width: 400px;
text-align: left;
height: 100%;
}
You will need the transform-origin property set to 0, 0
.write-note-container .nav .rotate {
/* Other properties */
background-color: red;
transform-origin: 0 0;
}
Demo
add transform origin to control the origin of the rotation.
transform-origin: 0 0;
http://jsfiddle.net/ges7L/4/
I've got a div that looks like a orange square
I'd like to draw a white X in this div somehow so that it looks more like
Anyway to do this in CSS or is it going to be easier to just draw this in Photoshop and use the image as the div background? The div code just looks like
div {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
You want an entity known as a cross mark:
http://www.fileformat.info/info/unicode/char/274c/index.htm
The code for it is ❌ and it displays like ❌
If you want a perfectly centered cross mark, like this:
try the following CSS:
div {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
position: relative;
}
div:after {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
content: "\274c"; /* use the hex value here... */
font-size: 50px;
color: #FFF;
line-height: 100px;
text-align: center;
}
See Demo Fiddle
Cross-Browser Issue
The cross-mark entity does not display with Safari or Chrome. However, the same entity displays well in Firefox, IE and Opera.
It is safe to use the smaller but similarly shaped multiplication sign entity, × which displays as ×.
single element solution:
body{
background:blue;
}
div{
width:40px;
height:40px;
background-color:red;
position:relative;
border-radius:6px;
box-shadow:2px 2px 4px 0 white;
}
div:before,div:after{
content:'';
position:absolute;
width:36px;
height:4px;
background-color:white;
border-radius:2px;
top:16px;
box-shadow:0 0 2px 0 #ccc;
}
div:before{
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
transform:rotate(45deg);
left:2px;
}
div:after{
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-45deg);
transform:rotate(-45deg);
right:2px;
}
<div></div>
Yet another pure CSS solution (i.e. without the use of images, characters or additional fonts), based on #Bansoa is the answer's answer .
I've simplified it and added a bit of Flexbox magic to make it responsive.
Cross in this example automatically scales to any square container, and to change the thickness of its lines one have just to tune height: 4px; (to make a cross truly responsive, you may want to set the height in percents or other relative units).
div {
position: relative;
height: 150px; /* this can be anything */
width: 150px; /* ...but maintain 1:1 aspect ratio */
display: flex;
flex-direction: column;
justify-content: center;
}
div::before,
div::after {
position: absolute;
content: '';
width: 100%;
height: 4px; /* cross thickness */
background-color: black;
}
div::before {
transform: rotate(45deg);
}
div::after {
transform: rotate(-45deg);
}
<div></div>
You can make a pretty nice X with CSS gradients:
demo: https://codepen.io/JasonWoof/pen/rZyRKR
code:
<span class="close-x"></span>
<style>
.close-x {
display: inline-block;
width: 20px;
height: 20px;
border: 7px solid #f56b00;
background:
linear-gradient(45deg, rgba(0,0,0,0) 0%,rgba(0,0,0,0) 43%,#fff 45%,#fff 55%,rgba(0,0,0,0) 57%,rgba(0,0,0,0) 100%),
linear-gradient(135deg, #f56b00 0%,#f56b00 43%,#fff 45%,#fff 55%,#f56b00 57%,#f56b00 100%);
}
</style>
Yet another attempt... this one uses ×. A lot of the examples on this page only show for me as a box, but × works
HTML
<div class="close"></div>
CSS
.close {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
.close:after {
position:relative;
content:"\d7";
font-size:177px;
color:white;
font-weight:bold;
top:-53px;
left:-2px
}
JSFIDDLE
You could just put the letter X in the HTML inside the div and then style it with css.
See JSFiddle: http://jsfiddle.net/uSwbN/
HTML:
<div id="orangeBox">
<span id="x">X</span>
</div>
CSS:
#orangeBox {
background: #f90;
color: #fff;
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 2em;
font-weight: bold;
text-align: center;
width: 40px;
height: 40px;
border-radius: 5px;
}
You can use the CSS property "content":
div {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
div:after {
content: "X";
font-size: 2em;
color: #FFF;
}
Like this:
http://jsfiddle.net/HKtFV/
#x{
width: 20px;
height: 20px;
background-color:orange;
position:relative;
border-radius:2px;
}
#x::after,#x::before{
position:absolute;
top:9px;
left:0px;
content:'';
display:block;
width:20px;
height:2px;
background-color:red;
}
#x::after{
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#x::before{
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
<div id=x>
</div>
I love this question! You could easily adapt my code below to be a white × on an orange square:
Demo fiddle here
Here is the SCSS (which could easily be converted to CSS):
$pFontSize: 18px;
p {
font-size: $pFontSize;
}
span{
font-weight: bold;
}
.x-overlay,
.x-emoji-overlay {
position: relative;
}
.x-overlay,
.x-emoji-overlay {
&:after {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
color: red;
text-align: center;
}
}
.x-overlay:after {
content: '\d7';
font-size: 3 * $pFontSize;
line-height: $pFontSize;
opacity: 0.7;
}
.x-emoji-overlay:after {
content: "\274c";
padding: 3px;
font-size: 1.5 * $pFontSize;
line-height: $pFontSize;
opacity: 0.5;
}
.strike {
position: relative;
display: inline-block;
}
.strike::before {
content: '';
border-bottom: 2px solid red;
width: 110%;
position: absolute;
left: -2px;
top: 46%;
}
.crossed-out {
/*inspired by https://www.tjvantoll.com/2013/09/12/building-custom-text-strikethroughs-with-css/*/
position: relative;
display: inline-block;
&::before,
&::after {
content: '';
width: 110%;
position: absolute;
left: -2px;
top: 45%;
opacity: 0.7;
}
&::before {
border-bottom: 2px solid red;
-webkit-transform: skewY(-20deg);
transform: skewY(-20deg);
}
&::after {
border-bottom: 2px solid red;
-webkit-transform: skewY(20deg);
transform: skewY(20deg);
}
}
You could do this by styling an "x"
text-align: center;
font-size: 120px;
line-height: 100px;
color: white;
font-family: monospace;
http://jsfiddle.net/Ncvyj/1/
Here is a single div and dynamic size version without using pseudo element.
body {
display: flex;
gap: 30px;
}
.x {
--color: #444;
--l: 5px; /* line-width */
width: 50px;
height: 50px;
background: linear-gradient(to top right, transparent calc(50% - var(--l) / 2), var(--color) calc(50% - var(--l) / 2) calc(50% + var(--l) / 2), transparent calc(50% + var(--l) / 2)),
linear-gradient(to bottom right, transparent calc(50% - var(--l) / 2), var(--color) calc(50% - var(--l) / 2) calc(50% + var(--l) / 2), transparent calc(50% + var(--l) / 2));
--clip-path: polygon(var(--l) 0%, calc(100% - var(--l)) 0%, 100% var(--l), 100% calc(100% - var(--l)), calc(100% - var(--l)) 100%, var(--l) 100%, 0% calc(100% - var(--l)), 0% var(--l));
-webkit-clip-path: var(--clip-path);
clip-path: var(--clip-path);
}
<div class="x"></div>
<div class="x" style="--l: 10px;"></div>
<div class="x" style="--l: 15px; --color: red"></div>
<div class="x" style="--l: 15px; --color: dodgerblue; width: 100px; height: 100px;"></div>
HTML
<div class="close-orange"></div>
CSS
.close-orange {
height: 100px;
width: 100px;
background-color: #FA6900;
border-radius: 5px;
}
.close-orange:before,.close-orange:after{
content:'';
position:absolute;
width: 50px;
height: 4px;
background-color:white;
border-radius:2px;
top: 55px;
}
.close-orange:before{
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
transform:rotate(45deg);
left: 32.5px;
}
.close-orange:after{
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-45deg);
transform:rotate(-45deg);
left: 32.5px;
}
https://jsfiddle.net/cooperwebdesign/dw4xd289/
A modern answer with good browser support.
<span>×</span>
This technically puts the multiplication symbol there, but no one will really notice (found some websites that have a popup box and most use this for the x button).
If you need more control you can style it with color opacity etc...
example (index.html)
<span class="x-button">×</span>
styles.css
span.x-button {
color:gray;
opacity:0.7;
font-size:1.5em;
}
Result (first example)
<span>×</span>
Result (2nd example)
span {
color:gray;
opacity:0.7;
font-size:1.5em;
}
<span class="x-button">×</span>
Note: you can highlight this unlike other solutions, but this may not be desirable depending on the application. You can solve this in pure css too, just add
user-select:none;
-webkit-user-select:none;
This is an adaptable version of the amazing solution provided by #Gildas.Tambo elsewhere in this page.
Simply change the values of the variables at the top to change the size of the "X".
Credit for the solution itself goes to Gildas. All I've done is given it adaptable math.
:root {
/* Width and height of the box containing the "X" */
--BUTTON_W: 40px;
/* This is the length of either of the 2 lines which form the "X", as a
percentage of the width of the button. */
--CLOSE_X_W: 95%;
/* Thickness of the lines of the "X" */
--CLOSE_X_THICKNESS: 4px;
}
body{
background:blue;
}
div{
width: var(--BUTTON_W);
height: var(--BUTTON_W);
background-color:red;
position: relative;
border-radius: 6px;
box-shadow: 2px 2px 4px 0 white;
}
/* The "X" in the button. "before" and "after" each represent one of the two lines of the "X" */
div:before,div:after{
content: '';
position: absolute;
width: var(--CLOSE_X_W);
height: var(--CLOSE_X_THICKNESS);
background-color:white;
border-radius: 2px;
top: calc(50% - var(--CLOSE_X_THICKNESS) / 2);
box-shadow: 0 0 2px 0 #ccc;
}
/* One line of the "X" */
div:before{
-webkit-transform:rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
left: calc((100% - var(--CLOSE_X_W)) / 2);
}
/* The other line of the "X" */
div:after{
-webkit-transform:rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
right: calc((100% - var(--CLOSE_X_W)) / 2);
}
<div></div>
Check & and Cross:
<span class='act-html-check'></span>
<span class='act-html-cross'><span class='act-html-cross'></span></span>
<style type="text/css">
span.act-html-check {
display: inline-block;
width: 12px;
height: 18px;
border: solid limegreen;
border-width: 0 5px 5px 0;
transform: rotate( 45deg);
}
span.act-html-cross {
display: inline-block;
width: 10px;
height: 10px;
border: solid red;
border-width: 0 5px 5px 0;
transform: rotate( 45deg);
position: relative;
}
span.act-html-cross > span { {
transform: rotate( -180deg);
position: absolute;
left: 9px;
top: 9px;
}
</style>