I'm trying to make such a stuff
But somehow I got something like the one below(Please ignore the color, font family for now)
My code is here.
HTML:
<div class="box">
<p>Instagram Photo</p>
</div>
<hr>
CSS:
.box{
background-color:red;
width:60%;
margin-left:20%;
height:30px;
z-index:3;
position:static;
}
.box p{
text-align:center;
color:white;
line-height:30px;
}
hr {
border-top: 1px solid red;
border-bottom: 1px solid blue;
z-index:-1;
margin-top:-15px;
position:static;
}
Change position: static to position: relative for the box.
CSS-Tricks reference
z-index only effects elements that have a position value other than
static (the default).
.box {
background-color: red;
width: 60%;
margin-left: 20%;
height: 30px;
z-index: 3;
position: relative;
}
.box p {
text-align: center;
color: white;
line-height: 30px;
}
hr {
border-top: 1px solid red;
border-bottom: 1px solid blue;
z-index: -1;
margin-top: -15px;
position: static;
}
<div class="box">
<p>Instagram Photo</p>
</div>
<hr>
I tried to make it exactly like the image you put.
Whenever you want to put an HTML element above or beneath another element, use the z-index property. The more the value of the z-index, it will be more on the above, and vice versa
.box{
background-color: #F8931F;
position: absolute;
width: 200px;
text-align: center;
color: #fff;
padding: 5px;
text-transform: uppercase;
left: 50%;
top: 40px;
transform: translate(-50%,0);
}
.seperator{
width: 100%;
height: 2px;
position: absolute;
background-color: #F8931F;
top: 52px;
z-index: -1;
}
<div class="box">instagram photos</div>
<div class="seperator"></div>
One suggestion is to use :after for the border.
.box{
height:30px;
z-index:3;
position:static;
}
.box p{
background-color:red;
text-align:center;
color:white;
line-height:30px;
margin: 0;
margin-left:20%;
width:60%;
}
.box:after{
border-top: 1px solid red;
border-bottom: 1px solid blue;
content: '';
display: block;
z-index:-1;
top:-15px;
position: relative;
width: 100%;
height: 0px;
}
<div class="box">
<p>Instagram Photo</p>
</div>
http://jsfiddle.net/afelixj/nrEfm/50/
Related
I have to code a shape(below image) in HTML
And below is the code what I tried so far:
body {
font: 13px Verdana;
}
h3 {
height: 100px;
background: #72bbab;
border-radius: 50px 10px 10px 50px;
display: flex;
margin-top: 50px;
position: relative;
line-height: 100px;
color: #ffffff;
font-size: 13px;
font-weight: normal;
}
h3 i {
width: 130px;
height: 130px;
transform: translateY(-15px);
background: #71bbab;
border-radius: 50%;
position: relative;
margin-right: 20px;
}
h3:before {
content: "";
position: absolute;
border: 1px dashed #fff;
top: 5px;
bottom: 5px;
left: 20px;
right: 2px;
border-radius: 10px;
}
h3 i:before {
content: "";
position: absolute;
top: 5px;
bottom: 5px;
left: 5px;
right: 5px;
border: 1px dashed #fff;
border-radius: 50%;
}
<h3><i></i>Text</h3>
Now the issue is I am not able to remove dashed border of circle from right side. I tried border-top:0 and border-right:0 but didn't work.
Thanks in advance
Note: Don't want to use any king of image
If you need to get the output by keeping same HTML mark-up then you have to use many pseudo selectors, CSS calc() function to calculate h2 tag width and many such properties to get output using CSS.
You have too even use position and z-index to hide circle border backside of h2 tag. And using margin you could arrange the remaining, so at one point whole diagram connects.
body {
font: 13px Verdana;
}
h3{
background:#72bbab;
width:calc(100% - 95px);
height:85px;
margin-left:95px;
margin-top:21px;
display:flex;
justify-content:flex-start;
align-items:center;
border-top-right-radius:10px;
border-bottom-right-radius:10px;
padding-left:20px;
box-sizing:border-box;
color:#fff;
}
h3 i{
width:120px;
height:120px;
background:#72bbab;
border-radius:50%;
display:inline-block;
top:2px;
left:2px;
position:absolute;
z-index:-1;
overflow:hidden;
}
h3 i:before{
content:"";
width:100px;
height:100px;
border:2px dashed #fff;
position:absolute;
top:8px;
left:8px;
border-radius:50%;
}
h3:before{
content:"";
width:calc(100% - 120px);
height:65px;
border:2px dashed #fff;
position:absolute;
right:15px;
border-top-right-radius:10px;
border-bottom-right-radius:10px;
}
h3:after{
content:"";
width:3px;
height:68px;
background:#72bbab;
position:absolute;
top:28px;
margin-left:-61px;
}
<h3><i></i>Text</h3>
See if this helps.
https://jsfiddle.net/induprakash/8ofLjqxm/
I added a higher z-index to rectangle border.
body {
font: 13px Verdana;
}
h3 {
height: 100px;
background: #72bbab;
border-radius: 50px 10px 10px 50px;
display: flex;
margin-top: 50px;
position: relative;
line-height: 100px;
color: #ffffff;
font-size: 13px;
font-weight: normal;
}
h3 i {
width: 130px;
height: 130px;
transform: translateY(-15px);
background: #71bbab;
border-radius: 50%;
position: relative;
margin-right: 20px;
}
h3:before {
content: "";
position: absolute;
border: 1px dashed #fff;
top: 5px;
bottom: 5px;
left: 105px;
z-index: 10;
right: 2px;
border-radius: 0px;
border-left: 0;
}
h3 i:before {
content: "";
position: absolute;
top: 5px;
bottom: 5px;
left: 5px;
right: 5px;
border: 1px dashed #fff;
border-radius: 50%;
border-right : 1px solid #72bbab;
}
Try this one, its running as per your image. I have tried a simple and different approach.
JSFiddle Link - https://jsfiddle.net/deepak104080/uwx873x1/
.circle {
width:130px;
height:130px;
border-radius:65px;
position:absolute;
z-index:100;
background:#71bbab;
margin:0px;
padding:0px;
}
.innercircle {
width:110px;
height:110px;
border-radius:55px;
position:absolute;
top:9px;
left:9px;
z-index:100;
background:#71bbab;
border: 1px dashed #fff;
}
.tab {
height: 100px;
position:absolute;
margin-top:15px;
margin-left:105px;
z-index:1000;
width:350px;
background:#71bbab;
border-top-right-radius:10px;
border-bottom-right-radius:10px;
}
.innertab {
height: 78px;
position:absolute;
margin-top:10px;
margin-left:0px;
z-index:1000;
width:340px;
background:#71bbab;
border-top-right-radius:10px;
border-bottom-right-radius:10px;
border-top: 1px dashed #fff;
border-bottom: 1px dashed #fff;
border-right: 1px dashed #fff;
}
<div>
<div class="circle">
<div class="innercircle">
</div>
</div>
<div class="tab">
<div class="innertab">
</div>
</div>
</div>
Use the ::after pseudo for h3 element.
h3:after {
z-index: 9999;
position:absolute;
max-width: 100%;
width: 100px;
height: 87px;
background: #71bbab;
content: '';
left: 35px;
margin-top: 6px;
}
https://jsfiddle.net/apyupfwo/
I am trying to recreate these borders over an image with CSS.
I have been able to create one border by using this CSS:
.bordered-image {
position: relative;
outline: 1px double white;
outline-offset: -10px;
}
But I have been unable to create the second border. Is it possible using CSS?
Hope the below code helps
body{
padding:50px;
}
.box{
width:300px;
height:200px;
border:1px solid red;
position:relative;
}
.box:after{
content:"";
position:absolute;
top:-4px;
bottom:-4px;
left:2px;
right:2px;
border:1px solid green;
}
<div class="box" >
</div>
Try the below code
<div class="module">
</div>
-
body {
padding: 20px;
}
.module {
width: 300px;
height: 200px;
position: relative;
border: 1px solid blue;
margin: auto;
}
.module:after {
content: "";
position: absolute;
top: -3px;
left: 1px;
right: 1px;
bottom: -3px;
border: 1px solid black;
margin:auto;
}
img {
border: 1px double black;
padding: 64px;
outline: 1px solid black;
box-sizing: border-box;
outline-offset: 20px;
}
something like this should work for you. You might have to play with the dimensions
body {
background: black;
}
.bordered-image {
position: relative;
height: 300px;
width: 300px;
border: 1px solid white;
margin: auto;
}
.bordered-image:before {
position: absolute;
left:-6px;
top: 4px;
display: block;
content: ' ';
margin: auto;
height: 290px;
width: 310px;
border: 1px solid white;
}
Try this:
.bordered-image {
background:black;
width:300px;
outline: 1px double white;
outline-offset: -10px;
}
.one {
width:300px;
height:300px;
position:relative;
border:1px solid white;
}
.one:after {
content: "";
width: 273px;
position: absolute;
top: 5px;
bottom: 5px;
left: 11px;
right: 2px;
border: 1px solid white;
}
<div class="bordered-image">
<div class="one">
</div>
</div>
I need "div2" to overlap/cover its two adjacent block. I can do it with "div1", but I cannot do it with "div3". Someone know how to do it? Please see my code below with what I have a problem. Thanks!
HTML:
<div class="parent">
<div class="child_1">Some div1</div>
<div class="child_2">Some div2</div>
<div class="child_3">Some div3</div>
</div>
CSS:
.parent {
position: relative;
font-size: 34px;
border: 1px solid #000;
background: #eef;
height: 110px;
width: 620px;
margin: 20px
}
.child_1 {
position: static;
text-align:center;
display: inline-block;
margin-top:20px;
margin-left:10px;
height: 50px;
width: 200px;
border: 3px solid yellow;
background:yellow;
}
.child_2 {
position: relative;
text-align:center;
display: inline-block;
margin-left:-30px;
height: 80px;
width: 200px;
border: 3px solid blue;
background:;
left:-30px;
top:-10px;
}
.child_3 {
position: relative;
display: inline-block;
text-align:center;
height: 50px;
width: 200px;
border: 3px solid yellow;
background:yellow;
left:-30px;
}
.child_3 needs to have left:-60px; in order to overlap .child_2
you have to add the -30px from .child_2to child_3, so -30px -30px = -60px
ADDITION: To really get child_2 to COVER child_3, assing z-index:1 to child_2:
.parent {
position: relative;
font-size: 34px;
border: 1px solid #000;
background: #eef;
height: 110px;
width: 620px;
margin: 20px;
}
.child_1 {
position: static;
text-align:center;
display: inline-block;
margin-top:20px;
margin-left:10px;
height: 50px;
width: 200px;
border: 3px solid yellow;
background:yellow;
}
.child_2 {
position: relative;
text-align:center;
display: inline-block;
margin-left:-30px;
height: 80px;
width: 200px;
border: 3px solid blue;
background:;
left:-30px;
top:-10px;
z-index:1;
}
.child_3 {
position: relative;
display: inline-block;
text-align:center;
height: 50px;
width: 200px;
border: 3px solid yellow;
background:yellow;
left:-60px;
}
<div class="parent">
<div class="child_1">Some div1</div>
<div class="child_2">Some div2</div>
<div class="child_3">Some div3</div>
</div>
You need to increase the negative left value on child3, and you need you use z-index to position child2 on top
In below sample I simplified your code a little.
.parent {
position: relative;
font-size: 34px;
border: 1px solid #000;
background: #eef;
height: 110px;
width: 600px;
margin: 20px;
}
.child {
position: relative;
display: inline-block;
height: 50px;
width: 200px;
margin: 20px;
text-align:center;
vertical-align: middle;
z-index: 1;
border: 3px solid yellow;
}
.child.nr1 {
background:yellow;
margin-right: -60px;
}
.child.nr3 {
background:yellow;
margin-left: -60px;
}
.child.nr2 {
height: 60px;
border: 3px solid blue;
z-index: 2;
}
<div class="parent">
<div class="child nr1">Some div1</div>
<div class="child nr2">Some div2</div>
<div class="child nr3">Some div3</div>
</div>
I just want to keep display table for container and display table-cell for h1 (to get it vertically centered) and I want to put an arrow under the h1 and out of the red div
my code is :
.container{
display:table;
width:200px;
height:50px;
background-color:red;
text-align:center;
}
.h1{
display:table-cell;
vertical-align:middle;
}
.sub{
width: 0px;
height: 0px;
position: absolute;
margin: 0px auto;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 30px solid black;
display: inline-block;
}
<div class="container">
<h1> title 1 </h1>
<div class="sub"></div>
</div>
I think this way is a little better:
http://jsfiddle.net/es_kaija/dqjb6kqr/15/
<div class="container">
<h1> title 1 </h1>
</div>
.container {
display:table;
width:200px;
height:50px;
background-color:red;
text-align:center;
position: relative;
}
h1 {
display:table-cell;
vertical-align:middle;
}
.container:after {
top: 100%;
left: 50%;
border: solid transparent;
content:" ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 0, 0, 0);
border-top-color: #000000;
border-width: 30px;
margin-left: -30px;
}
I want to align 3 different child div horizontally.
these 3 div contain 1 image (with height et width px). There is a link hover each div (but i want my onmouseover to be only over the image and not over the space left in the div).
So i don't want that my div take each 33% of the screen.
But i want my left image totally on the left side on the screen, my central image on center, and my third image totally on the right side of the screen
My parent div is absolute, and child div are relative with float (i don't know if is the good thing or not).
My example is here:
https://jsfiddle.net/mytom/eabgewnf/
My HTML:
<div class="controls">
<div class="controls_prev"></div>
<div class="controls_toggle"></div>
<div class="controls_next"></div>
</div>`
My CSS:
.controls {
position:absolute;
width:100%;
height:100px;
top:50%;
margin-top:-37px;
display:block;
}
.controls_prev {
opacity: 0.6;
position:relative;
width:78px;
height:100px;
float:left;
border: solid 1px #40b2d6;
}
.controls_toggle {
opacity: 0.6;
position:relative;
width:78px;
height:100px;
margin:0px auto !important;
border: solid 1px #40b2d6;
}
.controls_next {
opacity: 0.6;
position:relative;
width:78px;
height:100px;
float:right;
border: solid 1px #40b2d6;
}
-> My right div is not placed correctly.
how to do that?
I would do the following.
Use absolute positioning to place .controls_prev to the left and .controls_next to the right.
Keep .controls_toggle in regular flow and use margin: 0 auto to center it. This works well because both .controls_prev and .controls_next have the same width.
.controls {
position: absolute;
width: 100%;
height: 100px;
top: 50%;
margin-top: -37px;
display: block;
border: 1px dotted blue;
}
.controls_prev {
opacity: 0.6;
position: absolute;
width: 78px;
height: 100px;
top: 0px;
left: 0px;
border: solid 1px #40b2d6;
}
.controls_toggle {
opacity: 0.6;
width: 78px;
height: 100px;
margin: 0 auto;
border: solid 1px #40b2d6;
}
.controls_next {
opacity: 0.6;
position: absolute;
width: 78px;
height: 100px;
top: 0px;
right: 0px;
border: solid 1px #40b2d6;
}
<div class="controls">
<div class="controls_prev"></div>
<div class="controls_toggle"></div>
<div class="controls_next"></div>
</div>
Too many changes to list, but this should work. Note the reordering of the markup.
.controls {
position: absolute;
top: 50%;
right: 0;
bottom: 0;
left: 0;
margin-top: -37px;
background: #ddd;
}
.controls_prev {
opacity: 0.6;
position: relative;
width: 78px;
height: 100px;
float: left;
border: solid 1px #40b2d6;
}
.controls_toggle {
opacity: 0.6;
position: relative;
width: 78px;
height: 100px;
margin: 0 auto;
border: solid 1px #40b2d6;
}
.controls_next {
opacity: 0.6;
position: relative;
width: 78px;
height: 100px;
float: right;
border: solid 1px #40b2d6;
}
<div class="controls">
<div class="controls_prev"></div>
<div class="controls_next"></div>
<div class="controls_toggle"></div>
</div>
Try this.
.controls {
position: absolute;
width: 100%;
height: 100px;
top: 50%;
margin-top: -37px;
display: table;
table-layout: fixed;
}
.align {
display: table-cell;
vertical-align: top;
width: 100%;
padding:3px; /* just for show */
}
.inner {
border: solid 1px #40b2d6;
opacity: 0.6;
height: 100px;
}
<div class="controls">
<div class="controls_prev align">
<div class="inner"></div>
</div>
<div class="controls_toggle align">
<div class="inner"></div>
</div>
<div class="controls_next align">
<div class="inner"></div>
</div>
</div>
I've updated your fiddle to set each div's display to table-cell and added display: table to the container. Is this what you're after?
https://jsfiddle.net/eabgewnf/17/
CSS:
.controls{
position:absolute;
width:100%;
height:100px;
top:50%;
margin-top:-37px;
display:table;
}
.controls_prev{
display:table-cell;
opacity: 0.6;
height:100px;
border: solid 1px #40b2d6;
}
.controls_toggle{
display:table-cell;
opacity: 0.6;
height:100px;
top:0px;
left:0px;
border: solid 1px #40b2d6;
}
.controls_next{
display:table-cell;
opacity: 0.6;
height:100px;
border: solid 1px #40b2d6;
}
HTML:
<div class="controls">
<div class="controls_prev">left</div>
<div class="controls_toggle">this is the center</div>
<div class="controls_next">right</div>
</div>
To achieve that, I would use a table since is very useful. If you set the table width to 100vw (100% of the screen) and play with the percentages as you want.
.controls{
position:absolute;
width:100vw;
height:100px;
top:50%;
margin-top:-37px;
display:block;
table-layout: fixed;
}
.controls_prev{
opacity: 0.6;
width:20vw;
height:100px;
top:0px;
left:0px;
border: solid 1px #40b2d6;
}
.controls_toggle{
opacity: 0.6;
width:20vw;
height:100px;
top:0px;
left:0px;
border: solid 1px #40b2d6;
}
.controls_next{
opacity: 0.6;
width:20vw;
height:100px;
top:0px;
right:0px;
border: solid 1px #40b2d6;
}
.controls_separation{
width:20vw;
}
<table>
<tr class="controls">
<td class="controls_prev"></td>
<td class="controls_separation"></td>
<td class="controls_toggle"></td>
<td class="controls_separation"></td>
<td class="controls_next"></td>
</tr>
</table>