I have a border around my .tab-content and the same border around active .tabs. I've tried adding a transparent border on the bottom to no avail.
Is there a way to, where two borders overlap, have one override the other? Or is there a better way to accomplish this?
Here's a jsfiddle to show my basic set up.
.tab-content {
height:200px;
width:400px;
background-color: #aaa;
border:1px solid #000;
}
.tabs-container {
height:auto;
width:400px;
background-color:#aaabbb;
}
.tabs {
width:360px;
margin-left:20px;
}
.tab {
display:inline-block;
padding:5px 20px;
}
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
border-bottom:transparent;
background-color: #aaa;
}
<div class="tabs-container">
<div class="tabs">
<div class="tab active">This Tab</div>
<div class="tab">That Tab</div>
</div>
</div>
<div class="tab-content">
</div>
You can use a pseudo element to create the bottom border, make it the same color as the background, and position it to cover the dark line.
.tab.active:after {
content: '';
border-bottom: 10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
}
.tab-content {
height:200px;
width:400px;
background-color: #aaa;
border:1px solid #000;
}
.tabs-container {
height:auto;
width:400px;
background-color:#aaabbb;
}
.tabs {
width:360px;
margin-left:20px;
}
.tab {
display:inline-block;
padding:5px 20px;
}
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
background-color: #aaa;
position: relative;
}
.tab.active:after {
content: '';
border-bottom:10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
}
<div class="tabs-container">
<div class="tabs">
<div class="tab active">This Tab</div>
<div class="tab">That Tab</div>
</div>
</div>
<div class="tab-content">
</div>
Or just move the whole navbar 1px down.
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
background-color: #aaa;
position: relative;
bottom: -1px;
}
.tab-content {
height:200px;
width:400px;
background-color: #aaa;
border:1px solid #000;
}
.tabs-container {
height:auto;
width:400px;
background-color:#aaabbb;
}
.tabs {
width:360px;
margin-left:20px;
}
.tab {
display:inline-block;
padding:5px 20px;
}
.tab.active {
border-left:1px solid #000;
border-right:1px solid #000;
border-top:1px solid #000;
background-color: #aaa;
position: relative;
bottom: -1px;
}
/* .tab.active:after {
content: '';
border-bottom:10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
} */
<div class="tabs-container">
<div class="tabs">
<div class="tab active">This Tab</div>
<div class="tab">That Tab</div>
</div>
</div>
<div class="tab-content">
</div>
Related
I am trying to make a list of paragraphs, and one of them should be selected, just like the image below, but it seems I just cannot succeed.
I have tried something at: http://jsfiddle.net/bmj2j2wd/ but the end just just does not curve the way I would like it to... ie outwards, not inwards.
This is the css from there:
.active{
border:2px solid dodgerblue;
border-bottom:0;
width:80px;
height:32px;
margin:10px;
position:relative;
border-radius:16px 16px 0 0;
}
.active:after,
.active:before{
content:'';
width:80px;
height:32px;
border:2px solid dodgerblue;
position:absolute;
bottom:-8px;
border-top:0;
}
.active:after{
border-left:0;
border-radius:0 0 16px 0;
down:-16px;
}
.active:before{
border-right:0;
border-radius:0 0 0 16px;
up:-16px;
}
but it looks totally not right.
Very important would be that the two right lines after the curvature would go all the way up and down till the top and bottom of the page.
So, I'd like to ask for some help from the community in order to get this working.
You can basically use :before and :after to create a box on top and a box on bottom of your active <p> element (p.active). With these two boxes you can change the direction of the border. The following shows an example with a dynamic length based on the elements (Code on JSFiddle):
See the following solution (the original answer before edit):
.container :not(.active) {
border-right:1px solid dodgerblue;
margin:0;
padding:10px 10px 10px 20px;
width:72px;
}
.active {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
height:32px;
line-height:32px;
margin:10px;
padding-left:10px;
position:relative;
width:80px;
}
.active:after, .active:before {
border-right:1px solid dodgerblue;
content:'';
height:32px;
right:-2px;
position:absolute;
width:80px;
}
.active:after {
border-bottom-right-radius: 5px;
transform:translateY(-100%);
}
.active:before {
border-top-right-radius:5px;
transform:translateY(100%);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
</div>
You want to set vertical border on the full height of the page. This is a very difficult thing but you can use the following solution using a container which hides the overflow (the too long borders) (Code on JSFiddle):
body, html {
margin:0;
padding:0;
}
.container {
height:100vh;
margin:0;
overflow:hidden;
padding:0;
}
p {
display:block;
height:32px;
line-height:32px;
margin:10px;
padding:0;
padding-left:10px;
}
.active {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
position:relative;
width:80px;
}
.active:after, .active:before {
border-right:1px solid dodgerblue;
content:'';
height:100vh; /** same height like container */
position:absolute;
right:-2px;
width:80px;
}
.active:after {
border-bottom-right-radius:5px;
transform:translateY(-100%);
}
.active:before {
border-top-right-radius:5px;
transform:translateY(32px);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
<p>item7</p>
</div>
An additional, maybe useful, example using :hover instead of .active to set the active element. This is useful for tests too (Code on JSFiddle):
body, html {
margin:0;
padding:0;
}
.container {
height:80vh;
margin:0;
overflow:hidden;
padding:0;
}
p {
border:1px solid transparent;
display:block;
height:32px;
line-height:32px;
margin:10px;
padding:0;
padding-left:10px;
}
p:hover {
border:1px solid dodgerblue;
border-radius:5px 0 0 5px;
border-right:0;
position:relative;
width:80px;
}
p:hover:before, p:hover:after {
border-right:1px solid dodgerblue;
content:'';
height:100vh; /** same height like container */
position:absolute;
right:-2px;
width:80px;
z-index:-1;
}
p:hover:after {
border-bottom-right-radius:5px;
transform:translateY(-100%);
}
p:hover:before {
border-top-right-radius:5px;
transform:translateY(32px);
}
<div class="container">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p class="active">item4</p>
<p>item5</p>
<p>item6</p>
<p>item7</p>
</div>
You could use :after and :before pseudo elements and add border-radius.
.active {
padding: 15px;
margin: 60px;
border: 1px solid blue;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
padding-right: 0;
display: inline-block;
border-right: none;
position: relative;
}
.active:before,
.active:after {
content: '';
position: absolute;
width: 30px;
height: 40px;
}
.active:before {
border-right: 1px solid blue;
border-bottom: 1px solid blue;
border-bottom-right-radius: 50%;
right: -30px;
top: 0;
transform: translateY(-100%);
}
.active:after {
border-right: 1px solid blue;
border-top: 1px solid blue;
border-top-right-radius: 50%;
right: -30px;
bottom: 0;
transform: translateY(100%);
}
<div class="active">Some selection</div>
Another option that uses span elements for the curved lines, instead of pseudoelements
fiddle
body {
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.active {
border: 1px solid red;
border-right: 0;
width: 80px;
height: 32px;
position: relative;
border-radius: 5px 0 0 5px;
display: flex;
align-items: center;
padding-left: 1em;
}
.curvy {
flex: 1;
width: 80px;
margin-left: 30px;
border: 1px solid red;
border-left: 0;
border-top: 0;
border-radius: 0 0 5px 0;
margin-bottom: -1px;
}
.active+.curvy {
margin-bottom: 0;
margin-top: -1px;
border-top: 1px solid red;
border-radius: 0 5px 0 0;
border-bottom: 0;
}
<span class="curvy"></span>
<div class="active">hi</div>
<span class="curvy"></span>
While the other two works but it was not all the way up & down.
To make the line longer/shorter, change the height & top value.
height: 50vh;
top: calc(-50vh - 1px);
.active{
border:1px solid red;
border-right:0;
width:80px;
height:32px;
margin: 150px auto 0;
position:relative;
border-radius: 10px 0px 0 10px;
padding: 10px;
}
.active:after,
.active:before {
content: '';
position: absolute;
width: 20px;
height: 50vh;
}
.active:before {
top: calc(-50vh - 1px);
right: -20px;
border-bottom-right-radius: 10px;
border: 1px solid red;
border-left: none;
border-top: none;
}
.active:after{
bottom: calc(-50vh - 1px);
right: -20px;
border-top-right-radius: 10px;
border: 1px solid red;
border-left: none;
border-bottom: none;
}
<div class="active">hi</div>
First, I know there are similar questions available (like. Create concave corners in css) but they don't really cover this situation.
This is not about single cell/div element.
I have three blocks that will have some text content inside:
top-middle centered block (narrow)
middle-middle block (screen-wide)
bottom-middle centered block (narrow)
Basically something like a cross (text removed):
The outer corners (8) is straighforward but how could I achieve those inner ones (4)?
see bellow code, maybe it needs some adjustments but the idea is that you use pseudo-elements to make those inner borders
let me know if this is what you want
.colored {
background:yellow;
border:5px solid green;
width:100px;
height:100px;
box-sizing:border-box;
position:relative;
}
#content {
width:300px;
position:relative;
background:#000;
}
.top,.bottom { position:relative;margin:0 auto;clear:both}
.top { border-bottom:none}
.bottom { border-top:none}
.left { border-right:none}
.right { border-left:none;}
.colored.center { border:none;}
.left,.center,.right { float:left;}
.top { border-top-left-radius:10px;border-top-right-radius:10px;}
.bottom { border-bottom-left-radius:10px;border-bottom-right-radius:10px;}
.right { border-bottom-right-radius:10px;border-top-right-radius:10px;}
.left { border-bottom-left-radius:10px;border-top-left-radius:10px;}
.top:before {
position:absolute;
height:100%;
width:100%;
left:-100%;
top:5px;
content:"";
border-bottom-right-radius:10px;
border-right:5px solid green;
border-bottom:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.top:after {
position:absolute;
height:100%;
width:100%;
right:-100%;
top:5px;
content:"";
border-bottom-left-radius:10px;
border-left:5px solid green;
border-bottom:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.bottom:before {
position:absolute;
height:100%;
width:100%;
left:-100%;
bottom:5px;
content:"";
border-top-right-radius:10px;
border-right:5px solid green;
border-top:5px solid green;
z-index:9999;
box-sizing:border-box;
}
.bottom:after {
position:absolute;
height:100%;
width:100%;
right:-100%;
bottom:5px;
content:"";
border-top-left-radius:10px;
border-left:5px solid green;
border-top:5px solid green;
z-index:9999;
box-sizing:border-box;
}
<div id="content">
<div class="top colored">
</div>
<div class="left colored">
</div>
<div class="center colored">
</div>
<div class="right colored">
</div>
<div class="bottom colored">
</div>
</div>
Variation with just three divs, a bit hacky but functional. Uses pseudo elements, transforms and inner box-shadow.
div {
background-color: #000;
min-height: 100px;
}
.center {
width: 100px;
margin: 0 auto;
}
.rounded {
border-radius: 20px;
border: 5px solid red;
}
.conc {
position: relative;
}
.conc::before,
.conc::after {
content: '';
position: absolute;
border: 5px solid red;
border-radius: 20px;
width: 25px;
height: 25px;
background-color: trnaspanret;
border-color: red transparent transparent;
z-index: 3;
box-shadow: white 0px 0px 0px 20px inset
}
.conc.bottom {
margin-bottom: -5px;
border-bottom: 0;
border-radius: 20px 20px 0 0
}
.conc.top {
margin-top: -5px;
border-top: 0;
border-radius: 0 0 20px 20px
}
.conc::before {
left: -35px;
}
.conc::after {
right: -35px;
}
.conc.top::before,
.conc.top::after {
top: 0px;
}
.conc.bottom::before,
.conc.bottom::after {
bottom: 0px;
}
.conc.bottom::before {
transform: rotate(135deg)
}
.conc.bottom::after {
transform: rotate(-135deg)
}
.conc.top::before {
transform: rotate(45deg)
}
.conc.top::after {
transform: rotate(-45deg)
}
.centerblinders {
position: relative;
}
.centerblinders::before,
.centerblinders::after {
content: '';
position: absolute;
width: 130px;
height: 20px;
background-color: #000;
left: 50%;
transform: translatex(-50%);
z-index: 2;
}
.centerblinders::before {
top: -15px;
}
.centerblinders::after {
bottom: -15px;
}
<div class="rounded center conc bottom"></div>
<div class="rounded centerblinders"></div>
<div class="rounded center conc top"></div>
I suspect using line gradient?I know how to do the ellipse thing but I just don't understand how I can make the red line right through the middle?
I would make something like this: DEMO FIDDLE
CSS:
#container {
position: relative;
width: 200px;
background-color:black;
z-index:-2;
padding: 10px 0;
text-align:center;
}
#line {
position: absolute;
top: 50%;
width: 80%;
left:10%;
height: 1px;
box-shadow: 1px 1px 20px 5px red;
z-index:-1;
background-color: red;
}
#text{
color:white;
font-weight:bold;
text-transform:uppercase;
letter-spacing:8px;
text-shadow: 1px 1px 1px #ccc
}
HTML:
<div id="container">
<div id="text">Text</div>
<div id="line"></div>
</div>
I'm having some div and trying to add a plus character at the left side of the div after a h3 element. I've managed to add the plus with span but it won't go to the left side, it stays centered..
.wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.chatter
{
margin-top:5px;
width:70%;
border-spacing:5px;
table-layout: fixed;
empty-cells:show;
border-collapse:separate;
font:78%/130% "Arial", "Helvetica", sans-serif;
border:1px solid gray;
box-shadow:0px -1px 2px 1px #d2d6d8;
border-top:1px solid #eee;
border-right:1px solid #d2d5d7;
border-left:1px solid #d2d5d7;
border-bottom:1px solid #d2d5d7;
border-radius:3px;
font-size:large;
}
.c_head
{
box-shadow:0px -1px 2px 1px #d2d6d8;
border-top:1px solid #eee;
border-right:1px solid #d2d5d7;
border-left:1px solid #d2d5d7;
border-bottom:1px solid #d2d5d7;
padding-right:9px;
height:31px;
overflow:hidden;
margin-bottom:1px;
border-radius:3px;
}
.c_header
{
margin:0;
padding:0;
padding-left:9px;
color:#777777;
overflow:hidden;
height:31px;
line-height:31px;
font-size:1.2em;
font-weight:bold;
padding-bottom:3px;
}
<div class="wrapper" style="height:100%; background-color:Silver;">
<center>
<div class="chatter" runat="server">
<div class="c_head">
<h3 class="c_header">Chat - BETA<span style="text-align:left; padding-left:0; position:relative; left:0;">+</span></h3>
</div>
</div>
</center>
</div>
How can I possibly set it so it aligns to the left in the div? I've tried anything by now.
You could achieve that by positioning the <span> element absolutely and give a position of relative to the <div> to establish a containing block for the absolutely positioned element.
Then you could play with left or other offsets to move the element to the right position.
.wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.chatter {
margin-top:5px;
width:70%;
border-spacing:5px;
table-layout: fixed;
empty-cells:show;
border-collapse:separate;
font:78%/130% "Arial", "Helvetica", sans-serif;
border:1px solid gray;
box-shadow:0px -1px 2px 1px #d2d6d8;
border-top:1px solid #eee;
border-right:1px solid #d2d5d7;
border-left:1px solid #d2d5d7;
border-bottom:1px solid #d2d5d7;
border-radius:3px;
font-size:large;
margin-left: auto; /* <-- Added declarations */
margin-right: auto; /* instead of <center> */
text-align: center; /* dropped element. */
}
.c_head {
box-shadow:0px -1px 2px 1px #d2d6d8;
border-top:1px solid #eee;
border-right:1px solid #d2d5d7;
border-left:1px solid #d2d5d7;
border-bottom:1px solid #d2d5d7;
padding-right:9px;
height:31px;
overflow:hidden;
margin-bottom:1px;
border-radius:3px;
position: relative; /* <-- Added declaration */
}
.c_header {
margin:0;
padding:0;
padding-left:9px;
color:#777777;
overflow:hidden;
height:31px;
line-height:31px;
font-size:1.2em;
font-weight:bold;
padding-bottom:3px;
}
.c_header > span {
position:absolute; /* <-- Edited declaration */
left:0;
}
<div class="wrapper" style="height:100%; background-color:Silver;">
<div class="chatter" runat="server">
<div class="c_head">
<h3 class="c_header">Chat - BETA<span>+</span></h3>
</div>
</div>
</div>
As a side-note: <center> element has been deprecated since HTML 4 and removed since HTML 5 — But some web browsers still support it. Therefore it shouldn't be used for new projects.
Instead, in order to align block-level elements at the center you could set the left and right margin of the element toauto. And for inline-level elements, you could set text-align: center on the parent element.
I think you can just float it left? You might also then want to clear the float on the enclosing container.
.group:after {
content: "";
display: table;
clear: both;
}
...
<div class="c_head group">
<h3 class="c_header">Chat - BETA<span style="float:left; padding-left:0; position:relative; left:0;">+</span></h3>
</div>
Depends on which browsers you are supporting.
something like this?
HTML
<div class="wrapper" style="height:100%; background-color:Silver;">
<center>
<div class="chatter" runat="server">
<div class="c_head">
<div class="plus"> <h3> + </h3> </div>
<div class="c_header"> <h3>Chat - BETA</h3> </div>
</div>
</div>
</center>
</div>
CSS
.wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.chatter
{
margin-top:5px;
width:70%;
border-spacing:5px;
table-layout: fixed;
empty-cells:show;
border-collapse:separate;
font:78%/130% "Arial", "Helvetica", sans-serif;
border:1px solid gray;
box-shadow:0px -1px 2px 1px #d2d6d8;
border-top:1px solid #eee;
border-right:1px solid #d2d5d7;
border-left:1px solid #d2d5d7;
border-bottom:1px solid #d2d5d7;
border-radius:3px;
font-size:large;
}
.c_head
{
box-shadow:0px -1px 2px 1px #d2d6d8;
border-top:1px solid #eee;
border-right:1px solid #d2d5d7;
border-left:1px solid #d2d5d7;
border-bottom:1px solid #d2d5d7;
border-radius:3px;
}
.c_header
{
width:70%;
color:#777777;
height:100%;
font-size:1.2em;
font-weight:bold;
}
.plus {width:30%; height:100%; float:left; font-size:31px;}
http://jsfiddle.net/ockzukjs/
Remove the inline styles to the h3 in the HTML
.wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.chatter {
margin-top: 5px;
width: 70%;
border-spacing: 5px;
table-layout: fixed;
empty-cells: show;
border-collapse: separate;
font: 78%/130%"Arial", "Helvetica", sans-serif;
border: 1px solid gray;
box-shadow: 0px -1px 2px 1px #d2d6d8;
border-top: 1px solid #eee;
border-right: 1px solid #d2d5d7;
border-left: 1px solid #d2d5d7;
border-bottom: 1px solid #d2d5d7;
border-radius: 3px;
font-size: large;
}
.c_head {
box-shadow: 0px -1px 2px 1px #d2d6d8;
border-top: 1px solid #eee;
border-right: 1px solid #d2d5d7;
border-left: 1px solid #d2d5d7;
border-bottom: 1px solid #d2d5d7;
padding-right: 9px;
height: 31px;
overflow: hidden;
margin-bottom: 1px;
border-radius: 3px;
}
.c_header {
margin: 0;
padding: 0;
padding-left: 9px;
color: #777777;
overflow: hidden;
height: 31px;
line-height: 31px;
font-size: 1.2em;
font-weight: bold;
padding-bottom: 3px;
position: relative;
}
.c_header:before {
content: "+";
position: absolute;
left: 0;
}
.c_header:after {
content: "+";
position: absolute;
right: 0;
}
<div class="wrapper" style="height:100%; background-color:Silver;">
<center>
<div class="chatter" runat="server">
<div class="c_head">
<h3 class="c_header">Chat - BETA</h3>
</div>
</div>
</center>
</div>
What I did:
Changed this line of HTML
<h3 class="c_header">Chat - BETA</h3>
add this to CSS
.c_header
{
margin:0;
padding:0;
padding-left:9px;
color:#777777;
overflow:hidden;
height:31px;
line-height:31px;
font-size:1.2em;
font-weight:bold;
padding-bottom:3px;
position: relative;
}
.c_header:before {
content:"+";
position: absolute;
left:0;
}
.c_header:after {
content:"+";
position: absolute;
right:0;
}
I am trying to create the following (notice the 1 pixel gap at either end):
If you try:
<hr class="fancy">
with the following CSS:
hr.fancy {
border: 1px solid black;
border-width: 1px 0px;
color: black;
height: 5px;
position: relative;
}
hr.fancy:after {
content: '\A';
position: absolute;
bottom: -1px;
right: 0px;
display: block;
width: 1px;
height: 7px;
border-left: 1px solid white;
}
hr.fancy:before {
content: '\A';
position: absolute;
bottom: -1px;
left: 0px;
display: block;
width: 1px;
height: 7px;
border-right: 1px solid white;
}
Take a look at: http://jsfiddle.net/audetwebdesign/P7umD/
You can play with the pixel widths to get a bolder look.
Browser Compatibility
I checked this in Firefox and Chrome and the mark-up renders consistently.
However, does not work in IE9, you only get the double lines and not the book-ends.
Maybe border-image will do the trick
http://www.w3schools.com/cssref/css3_pr_border-image.asp
http://css-tricks.com/understanding-border-image/
Or you can use a div based solution
<div class="border">
Content
<div class="left"></div>
<div class="right"></div>
</div>
.border {
border-width:0px;
border-style: double;
border-color: grey;
border-bottom-width: 3px;
position: relative;
}
.left,
.right{
position: absolute;
width: 1px;
height: 3px;
bottom: -3px;
background-color: white;
}
.left {
left: 1px;
}
.right {
right: 1px;
}
http://jsfiddle.net/zCEKp/
This css-only solution may work for you:
html markup:
<div class="fancydivider">
<div class="left"> </div>
<div class="middle"> </div>
<div class="right"> </div>
</div>
css:
.fancydivider {
clear: both;
}
.fancydivider .left {
border-bottom: double black;
width: 1px;
float: left;
}
.fancydivider .middle {
border-bottom: double black;
width: 50px;
float: left;
margin: 0 1px 0 1px;
}
.fancydivider .right {
border-bottom: double black;
width: 1px;
float: left;
}
result:
http://jsfiddle.net/KNqR8/
http://jsfiddle.net/Lucidus/ZjGpS/1/
[edit: wrong css in first link - I don't know what happened ;-)]
Is this what you want?
HTML:
<div class="box">
<div class="top-left"></div>
<div class="top-right"></div>
<div class="bottom-left"></div>
<div class="bottom-right"></div>
</div>
CSS:
.box{
position:relative;
border:3px double;
width:100px;
height:50px;
}
.top-left, .top-right, .bottom-left, .bottom-right {
position:absolute;
width:4px;
height:4px;
border-left:1px #fff solid;
border-right:1px #fff solid;
}
.top-left, .top-right{
top:-4px;
}
.top-left, .bottom-left{
left:-4px;
}
.top-right, .bottom-right{
right:-4px;
}
.bottom-left, .bottom-right {
bottom:-4px;
}
Here's jsFiddle example.