How to create a border gap illusion - html

This is the illusion that I am attempting to create:
Notice that my designer wants the border cut off in the middle of the div, this is what I need to know how to do. I don't think overlapping with a z-index will work because of how the HTML is laid out.
This is the HTML code of which the structure may not be changed for maximum device compatibility, however, if adding an element is the solution, I believe that may be done:
<div id="nav_icons_con" class="mopn">
<div id="inner_nav_container" class="show_inner_nav">
<div class="nav_link_container">Home</div>
</div>
</div>
Here is the basic current CSS code:
#nav_icons_con {
z-index: 1;
cursor:pointer;
height: 5.005em;
width: 5.005em;background-image:url(background.png);
background-size:70%;
background-repeat:no-repeat;
background-position:center;
margin:.385em .385em 0 0;
}
#nav_icons_con.mopn{
background-color:#FFF;
border:2px solid #83C5E6;
border-bottom:none;
box-shadow:5px 5px 10px #666;
}
#inner_nav_container, .inner_nav_container{
cursor:pointer;
display:none;
position:absolute;
top:5.39em;
right:.385em;
width:12.5em;
white-space:normal;
background-color:#FFF;
border:2px solid #83C5E6;
border-top:none;
box-shadow:5px 5px 10px #666;
}
#inner_nav_container.show_inner_nav, .inner_nav_container.show_inner_nav{display:block;}

The typical way to do this is to position the tab element over the sub element, so as to cover up that section of the border. However, the use of box-shadow complicates this.
One way is to add another element inside the root element, so that the root element can still cast the shadow, but the element inside is positioned above. See my code below, for a basic example.
Working Example:
.icon {
width: 50px;
height: 50px;
position: relative;
/*Create the shape for the shadow.*/
border: 5px solid #83C5E6;
box-shadow: 5px 5px 10px #666;
}
.icon-content {
background: #fff;
position: relative;
/*Move back over the border.*/
top: -5px;
left: -5px;
/*Make tall enough to cover the top border.*/
width: 50px;
height: 55px;
/*Add border, except on the bottom.*/
border: 5px solid #83C5E6;
border-bottom: 0;
/*Position up a layer.*/
z-index: 1;
}
.nav {
position: absolute;
left: -5px;
top: 100%;
width: 400px;
padding: 1em;
background: #fff;
border: 5px solid #83C5E6;
box-shadow: 5px 5px 10px #666;
}
<div class="icon">
<div class="icon-content">
</div>
<div class="nav">
<div class="item">Home</div>
</div>
</div>

Related

Is there is a possible way to fill color between css double border? [duplicate]

This question already has an answer here:
Css - Need 'triple' border
(1 answer)
Closed 4 years ago.
Hello Guys I Would Like to Fill a Different Color in My css Double Border.I Know that it is Possible by Using Two Borders.
#parent{
width:100px;
height:100px;
border:1px solid #000;
display:flex;
align-items:center;
justify-content : center;
background-color:red;
}
#child{
width:80px;
height:80px;
border:1px solid #000;
background-color:#fff;
}
<div id="parent">
<div id="child"></div>
</div>
But here I would like to have a solution with a single Border Property(Single <div> or any other Element).So I Used css double Property.Is there is any Possible way to fill color on this double_border?
#element{
width:100px;
height:100px;
border:10px double #000;
}
<div id="element"></div>
Please Note :- Somebody Tagged That This is Possible Duplicate of
Another.Just Please Read Both of the Question before You Tagg. This
question is different,on that question he is asking for color the the
two borders with different color.but here I would like to keep two
borders with same color,I just wanna to fill some color between
them.hope you will understand the problem.
You could also use multiple box-shadows:
#element {
width: 100px;
height: 100px;
box-shadow: 0 0 0 3px #000, 0 0 0 6px #f00, 0 0 0 9px #000;
}
<div id="element"></div>
You can by using the border, box-shadow, and outline properties.
#element {
width: 100px;
height: 100px;
border: 3px solid black; /* inner border */
box-shadow: 0px 0px 0px 15px black; /* outer 'border' */
outline: 12px solid green; /* fill */
margin-left: 30px;
margin-top: 30px;
}
<div id="element"></div>
You can use a pseudo-element to accomplish this:
https://jsfiddle.net/82zn96Lu/
#doubleBorder {
text-align: center;
position: relative;
z-index: 10;
padding: 100px;
background: #fff;
border: 6px solid red;
}
#doubleBorder:before {
content: "";
display: block;
position: absolute;
z-index: -1;
top: 3px;
left: 3px;
right: 3px;
bottom: 3px;
border: 6px solid blue;
}
<div id="doubleBorder">
a double border
</div>

I'm trying to create a broken horizontal line with arrows on either end and text in the middle

I'm trying to create a responsive horizontal line with arrows on either end and text in the middle. I found ways to create the line with the text in the middle using before and after, but I'm stumped as to how to incorporate the arrows on either end. Ideally I would like to use a font icon, but am willing to use a generic html arrow if necessary.
This way you can achieve it:
Have the image as background.
Center align the text.
Give the text some background colour, matching the parent background colour.
Snippet
h1 {
font-size: 15pt;
font-weight: normal;
text-align: center;
background: url("http://www.signsbypost.com/sites/default/files/irun/uc_product/images/SELF-ADHESIVE-VINYL-STICK-ON-ARROW-DOUBLE-HEAD-5271.jpg") center center no-repeat;
background-size: contain;
}
h1 span {
display: inline-block;
padding: 5px;
background-color: #fff;
}
<h1><span>Hello</span></h1>
Preview
Only using CSS without images.
.line {
margin-top:8px;
width:10%;
background:blue;
height:3px;
float:left;
position:relative;
}
.arrowed .text{
padding: 0 10px 0 10px;
}
.arrowed span{
float:left;
display:block;
}
.line.first:before {
content: '';
position: absolute;
right: 100%;
top: -3px;
display:inline-block;
width: 0;
height: 0;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-right: 5px solid blue;
}
.line.second:after{
content: '';
position: absolute;
left: 100%;
top: -3px;
display:inline-block;
width: 0;
height: 0;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-left: 5px solid blue;
}
<p class="arrowed">
<span class="line first"></span>
<span class="text">Continuous Improvement</span>
<span class="line second"></span>
</p>

<div> with a sloped edge and box-shadow

How can I create the following mock-up in HTML and CSS?
I have tried adding a separated <div> to create the sloped edge using transform: rotate(); with no luck.
Mainly, what I want to achieve is:
Two <div> elements with content
The two <div> elements have sloped edges and shadows
The skew transformation can create the slope, but unfortunately it applies to the whole div, not just one edge of it. You can use overlapping or nested divs to mix straight and skewed edges on the same box - however, this makes the shadows a bit problematic (see http://jsfiddle.net/z9am39sp/).
Another weakness is that with this particular setup, you can't fit the text to the skewed shape.
Still, it may be close enough for your purposes. Your call.
I gave it a shot and here is my working fiddle.
I used CSS3 transform: skew on a pseudo element.
HTML
<div class="container">
<div class="slope">content 2</div>
<div class="slope">content 1
<br/>text</div>
<div class="slope">content 3
<br/>text
<br/>text</div>
</div>
CSS
*, *:before, *:after {
box-sizing: border-box;
}
body {
background: #ddd;
}
.container {
/*border: 1px solid red;*/
padding: 0 3px 0 0;
overflow: hidden;
}
.slope {
width: 100%;
padding: 5px;
margin: 0 0 40px;
position: relative;
background: #fff;
}
.slope:before {
content:"";
width: 100%;
height: calc(100% + 26px);
position: absolute;
top: -13px;
left: 0px;
z-index: -1;
background: #fff;
box-shadow: 1px 2px 3px 0px rgba(0, 0, 0, 0.4);
transform: skew(0deg, 2deg);
}
.slope:last-of-type {
margin-bottom: 5px;
box-shadow: 1px 2px 3px 0px rgba(0, 0, 0, 0.4);
}
.slope:last-of-type:before {
margin-bottom: 0px;
height: calc(0% + 26px);
box-shadow: none;
}
Notes:
You might need to play with the transform: skew(Ndeg) and height: calc(100% +
Npx) depending on the size of the divs
You might also need vendor prefixes
Not sure about responsiveness but according to my tests, it works
fine.
You can use the :before and :after selectors. You can read more about them here
Also here is a fiddle
Feel free to leave a comment if you have any other question.
HTML
<div class="div-1"> </div>
<div class="div-2"> </div>
CSS
body{
background:#ccc;
}
.div-1{
width:100px;
height:150px;
position:relative;
background:#fff;
}
.div-1:before{
content:"";
position:absolute;
border:20px solid transparent;
border-right:100px solid #fff;
border-top:0px;
bottom:-20px;
left:-20px;
}
.div-2{
width:100px;
height:50px;
position:relative;
background:#fff;
margin-top:30px;
}
.div-2:before{
content:"";
position:absolute;
border:20px solid transparent;
border-left:100px solid #fff;
border-bottom:0px;
top:-20px;
right:-20px;
}

My absolute image needs to be responsive

I'm having trouble getting my image to be responsive. It's a image that sits above another image, so I used absolute positioning. If I make the page smaller, everything gets all out of whack.
This is my css for the image that sits above the other image.
.page-header .logo img {
position: absolute;
top: 240%;
left: 126%;
width: 200px;
height: 150px;
padding:1px;
border:1px solid #021a40;
background-color:#000;
margin-top: -250px; /* Half the height */
margin-left: -250px; /* Half the width */
}
And this is the css for the image behind it.
.page .carousel img {
-webkit-border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
border-radius: 4px 4px 0 0;
}
How can I make the above image to resize properly with the image behind it?
Here's a little fiddle I put together to get you closer. Depending on the size of the logo, you'll have to adjust the percentages a little bit to get what you want.
HTML
<div class='page-header'>
<div class='carousel' id='portfolio-carousel'>
<img alt="1396051485478" src="http://www.placehold.it/650x350" class="bg" />
</div>
<div class="logo-wrap">
<img alt="Logo" src="http://www.placehold.it/250x150" class="logo" />
</div>
</div>
CSS
.page-header {
position:relative;
width:100%;
}
.logo-wrap {
width:100%;
position:absolute;
margin-top:-43%;
}
.logo {
position: absolute;
padding:1px;
border:1px solid #021a40;
background-color:#000;
top:22%;
left:25%;
width:50%;
}
.carousel {
position:relative;
width:100%;
}
.bg {
-webkit-border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
border-radius: 4px 4px 0 0;
width:100%;
}
Fiddle
http://jsfiddle.net/disinfor/9b332ghd/4/
I believe this will get you what you are looking for. Also, I may have changed some of your class names while I was troubleshooting it for you.

Put div on top of the text

I have been trying and I don't really know how to solve this:
I need to style the title of the content like this:
Now, I've been trying to have position:absolute some other stuff, but it just doesn't seem to work.
My code:
<div class="content_item">
<div class="double_line"></div>
<h2>Ce facem</h2>
</div>
css:
.content_item>div{
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
display:inline-block;
width:100%;
height:5px;
position: absolute;
}
.content_item>h2{
text-align: center;
background-color: #ffffff;
}
So what I wanted was to put the text over the line and a white background on the text.
fiddle: http://jsfiddle.net/Qu849/
Can you please help me?
This fiddle kinda works:
http://jsfiddle.net/Qu849/4/
Anyway I wouldn't do that code for this purpose. Consider this:
Just use a div with a background image (repeat-x) with those "borders"
Inside that div use a span, centered, and with a background:#fff;
That is just better.
EDIT
Check #drip answer to do what I described: https://stackoverflow.com/a/20070686/2600397
You need to position you h2 above your bordered div. My idea would be to make h2 display:inline-block; so you can use text-align:center; on the parent to center the child h2 and then just use position:relative; and top:-20px; on the h2 to move it up a bit
.content_item{
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
width:100%;
height:5px;
position:relative;
text-align:center;
margin-top:50px;
}
.content_item > h2{
text-align: center;
background-color: white;
padding:3px 15px;
font-size:14px;
display:inline-block;
position:relative;
top:-20px;
}
http://jsfiddle.net/Qu849/8/
Since the double_line div is absolutely positioned, it will be above any none positioned elements.
to put both elements on a relative plane, you need to position the h2 in the same manner (either absolute, or relative).
After that you can play with the margins or top/left properties of the elements to position them over each other.
You can do it with a backgruund image very easy.
If you are ok with using background images.
HTML:
<h2><span>Ce facem</span></h2>
CSS:
h2 {
background: url(http://i.imgur.com/7LGlQ0I.png) repeat-x 0 center;
text-align: center;
}
h2 span { padding: 0 20px; background-color: #fff; }
Demo
Or if you really prefer usin bordered element:
Then with a little tweaks in the css:
.content_item>div{
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
width:100%;
height:5px;
position: absolute;
top: 12px;
}
.content_item>h2{
display: inline;
position: relative;
z-index: 2;
text-align: center;
padding: 0 10px;
background-color: #ffffff;
}
.content_item{
text-align: center;
position:relative;
}
Demo
Yes, Rodik is right
Try using:
.content_item>h2 {
text-align: center;
display: block;
width: 200px;
background-color: #ffffff;
margin-top: -20px;
margin-left: 30%;}
You have to give position:absolute; and margin to your <h2>
Replace your <h2> style with this:
.content_item>h2{
text-align: center;
background-color: #ffffff;
position:absolute;
margin:-10px 41% 0px;
}
fiddle
if in doubt, you could just make the text an image with full transparent background, this makes it easier when it comes to responsive webpage layouts (different resolutions etc.)
Pure Css with No images
Ammend this in your CSS to check if it helps :
.content_item>h2{
text-align: center;
background-color: #ffffff;
display:inline-block; // makes header size equal to text width
width : 30%; //gives indented left-right white-space
position:absolute; //to overlay it on double-line
top : 0px; //position
display: table; //centre inline elements
margin : 0 auto;
margin-left : 40% //hack to center it
}
.content_item>div{
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
display: inline-block;
width: 100%;
height: 5px;
position: relative;
}
.content_item>h2{
background-color: #FFFFFF;
width: 200px;
z-index: 12;
position: absolute;
top: -23px;
text-align: center;
left: 0;
right: 0;
margin: 20px auto;
}
.content_item{
position:relative;
}
}
use this code usefull for you.
see this link http://jsfiddle.net/bipin_kumar/35T7S/1/
Here is one way of doing it:
.content_item {
position:relative;
}
.content_item > div {
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
XXdisplay:inline-block; /* not needed */
width:100%;
height:5px;
position: absolute;
z-index: -1;
top: 50%;
margin-top: -3px;
}
.content_item > h2 {
text-align: center;
background-color: #ffffff;
width: 200px; /* must be specified */
margin: 0 auto; /* for centering */
}
To the .double-line div, add z-index: -1 to force it to be painted under the h2 element.
Use top: 50% and a negative margin-top: -3px to vertically align the double lines (if that is what you need).
You then need to specified a width for h2 other wise it will be 100% wide and the white background will paint over the dobule-lines. Add margin: 0 auto to center the h2 within the parent container.
You do not need display: inline-block for the .double-line since the absolute positioning will force the display type to be block.
Demo at: http://jsfiddle.net/audetwebdesign/nB2a3/
You can do this without absolute positioning and without changing the HTML.
Rather than having the text-align: center on the <h2>, you can set it on the .content-item. Then use display: inline-block on the <h2> and relatively position it with a negative top value.
Like so:
.content_item>div {
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
width:100%;
height:5px;
}
.content_item>h2 {
background-color: #ffffff;
display: inline-block;
margin: 0;
padding: 0 40px;
position: relative;
top: -15px;
}
.content_item {
text-align: center;
}
http://jsfiddle.net/Qu849/11/
Try this, another way
.content_item>div{
border-top: 2px solid #c2c1c1;
border-bottom: 2px solid #a5a4a4;
display:inline-block;
width:100%;
height:5px;
position: relative;
}
.content_item>h2{
text-align: center;
background-color: #ffffff;
position:absolute;
margin-top:-30px;
margin-left:50%;
}
When z-index not used this type of issue, use above format.