bracket style border around elements - html

I'm looking for a way to implement a bracket style border around my <h2> headings; I've attached an image showing exactly what I'm trying to accomplish.
The only way I can think of to achieve this effect is by using images, but I'm unsure of exactly how to do so(all of my <h2>s are of varying length/height, or if maybe there is a better way.
Any tips & insight are greatly appreciated.
**I hate to resurrect this, but what can I look towards as being the solution to the problem shown int he updated image? The right line is too far right, as well as some opacity issues above and below the text..
UPDATE:

Working jsFiddle example.
Use the following. You just need to change the font of the text or replace it for an image, and maybe change the color of the borders to match yours.
For the HTML:
<div id="h2pre"></div>
<h2>
<div id="h2inpre"></div>
<div id="h2cont">Ready for the event of a lifetime?<br/>
We'd love to hear from you.
</div>
<div id="h2inpos"></div>
</h2>​
For the CSS:
h2{
text-align:center;
position:relative;
margin-left:50%;
left:-150px
}
div{ float:left; }
#h2inpre, #h2inpos{
background-color:#fff;
height:50px;
width:20px;
border-bottom:1px solid #FFA500;
border-top:1px solid #FFA500;
}
#h2inpre{
border-left:1px solid #FFA500;
}
#h2inpos{
border-right:1px solid #FFA500;
clear:right;
}
#h2cont{
font-family:"Arial",sans-serif;
padding:5px;
background-color:#fff;
}
#h2pre{
height:1px;
width:100%;
background-color:#FFA500;
margin-top:25px;
position:absolute;
float:none;
}
​

html:
<h2 class="bracket"><span class="text">Ready for the event of a lifetime?<br>We'd love to hear from you.</span></h2>
css:
.bracket {
position: relative;
text-align: center;
color: #999;
font-size: 1.2em;
}
.bracket:before {/* vertical stripe */
content: " ";
border-top: solid 1px orange;
position: absolute;
bottom: 50%;
left: 0;
right: 0;
}
.bracket .text {
position: relative;
display: inline-block;
background: #fff;
padding: .2em 1em;
max-width: 80%;/* force that at least some of vertical stripe is still shown */
}
.bracket .text:before {/*left bracket*/
content: " ";
border: solid 1px orange;
border-right: 0px;
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: .4em;
right: 0;
}
.bracket .text:after {/*right bracket*/
content: " ";
border: solid 1px orange;
border-left: 0px;
position: absolute;
right: 0;
top: 0;
bottom: 0;
width: .4em;
right: 0;
}
demo: http://jsbin.com/ibiyal/2
You'll probably have to tinker with the padding of the text block, and the width of the left and right bracket.
Only downside is that it only works on a solid background.

It is perfectly possible. Take a look: http://tinkerbin.com/zQ1VWLLi
The HTML...
<h2 class="box">
<span>Ready for the event of a lifetime? <br/> We'd love to hear from you.</span>
</h2>
The CSS...
h2:before,
h2 span:before,
h2 span:after {
content: "";
position: absolute;
}
h2 {
position: relative;
font: 16px/1.2em cambria;
text-align: center;
}
h2:before {
top: 50%;
height: 1px; width: 100%;
background-color: orange;
}
h2 span {
display: block;
width: 50%;
padding: 7px;
margin: 0 auto;
position: relative;
background: /*same as background where it sits*/;
border: 1px solid orange;
}
h2 span:before,
h2 span:after {
left: 7%; right: 7%;
height: 1px;
background: /*same as background where it sits*/;
}
h2 span:before {
top: -1px;
}
h2 span:after {
bottom: -1px
}

You could do this with HTML and CSS.
CSS
#container {
position: relative;
height: 43px;
}
#bracks {
background-color: #fff;
margin:0 auto;
border: 1px solid black;
width: 200px;
height: 40px;
position: relative;
}
#text {
background-color: #fff;
position: absolute;
width: 150;
left: 15;
height: 22px;
top: -1;
padding: 10px;
text-align: center;
}
#strike {
position: absolute;
top: 21;
width: 100%;
border-top: 1px solid black;
}
HTML
<div id="container">
<div id="strike"> </div>
<div id="bracks">
<div id="text">Some text here.</div>
</div>
</div>

Related

How to cut a corner with CSS when background image is necessary?

The above is an image of a project I'm working on. This is how far I got:
Creating the box was fairly simple; however, now I have NO IDEA how to create this cut corner on the bottom left. I've tried a bunch of things already and most things work if the background isn't transparent but a block of color. Since the background needs to be this image, I can't make the cut corner work without having one side show a certain color. This is my code:
<div class="profile">
// HTML content
</div>
<style>
profile {
border: 2px solid #fff;
color: #fff;
height: 100%;
padding: 10px;
width: 250px;
</style>
I've tried multiple things already, such as this here (not the exact code I used, but I followed this example):
.cut {
border: none;
position: relative;
}
.cut:before {
content: "";
position: absolute;
bottom: 0;
right: 0;
border-bottom: 20px solid lightgrey;
border-left: 20px solid #e67e22;
width: 0;
}
This creates a cut corner, but with a block of a solid color and I need the image to be shown, not the color.
Does anyone have a clue how to do this? Suggestions are much appreciated. Thanks!
You may use before/after element to make the bottom part like this :
.profile {
position:relative;
display:inline-block;
margin:50px;
border:1px solid #000;
border-bottom:none;
width:100px;
height:200px;
background:#ccc;
}
.profile:after {
content:" ";
position:absolute;
border:1px solid #000;
height:20px;
width:80px;
bottom:-20px;
right:-1px;
border-top:0;
border-left:0;
background:#ccc;
}
.profile:before {
content:" ";
position:absolute;
border-bottom:1px solid #000;
height:29px;
width:29px;
transform:rotate(45deg);
bottom:-15px;
left:6px;
background:#ccc;
}
<div class="profile"></div>
the bottom is split into tow part : a rectangle with only two border + a square with one border rotated with 45°
Hope it helps
NB : Becarefull when changing the dimensions
.profile {
position: relative;
display: inline-block;
width: 200px;
height: 200px;
border-top: 2px solid #000;
border-left: 2px solid #000;
border-right: 2px solid #000;
padding: 20px;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
.profile h2 {
margin: 0 0 10px;
}
.profile p {
font-size: 14px;
}
.profile .bottom {
position: absolute;
bottom: -30px;
right: -2px;
width: 180px;
height: 30px;
border-bottom: 2px solid #000;
box-sizing: border-box;
border-right: 2px solid #000;
}
.profile .bottom::before {
content: '';
position: absolute;
left: -10px;
bottom: -4px;
width: 2px;
height: 35px;
background-color: #000;
transform: rotate(-35deg);
}
<div class="profile">
<h2>Name</h2>
<p>Description</p>
<div class="bottom"></div>
</div>
I think you're trying to cut the corner of an image instead of div, so you can do something like this:
body {
background: url('https://www.lunapic.com/editor/premade/o-paint-bucket.gif');
}
.container {
display: inline-block;
width: 200px;
height: 300px;
overflow: hidden;
}
.container .image_container {
width: 320px;
height: 550px;
overflow: hidden;
display: block;
position: relative;
transform: rotate(45deg);
margin-left: calc(260px - 360px);
margin-top: -40px;
}
.container .image_container .image {
transform: rotate(-45deg);
margin-top: 10px;
margin-left: -10px;
}
<div class="container">
<div class="image_container">
<div class="image">
<img src="https://www.w3schools.com/css/img_fjords.jpg" />
</div>
</div>
</div>

Add arrow to cancel alert to look like popover

I have this code:
How can I make it have that arrow thing at the top:
like this:
so it can look like a popup?
Here is the styling for it:
.div-cancel{
background-color: #FAFAFA;
width:200px;
display:none;
height:85px;
font-size:15px;
padding-top:18px;
padding-left:10px;
padding-right:10px
}
<div class="div-cancel" id="cancel101" >
<span><span style="background-color: #FAAB20;"><i class="fa fa-exclamation" style="width:25px;color:white"></i></span>
Please type in 'CANCEL' to cancel subscription. </span>
</div>
Here is the demo.
The Css solution is:
.div-cancel {
background-color: #1E2021;
width:200px;
display:block;
height:85px;
font-size:15px;
padding-top:18px;
padding-left:10px;
padding-right:10px;
position: relative;
color: #ababab;
}
.div-cancel:before {
position: absolute;
content: '';
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom-color: #1E2021;
left: 10px;
top: -12px;
}
You can use this CSS with the unchanged HTML shown in the question.
If you want a border around your arrow, using transform on the ::before pseudo element and some positioning, can get the affect that you want without any added markup. Just make sure div-cancel has it's position set to relative.
.div-cancel {
position: relative;
margin-top: 20px;
background-color: #FAFAFA;
width: 200px;
height: 85px;
font-size: 15px;
padding-top: 18px;
padding-left: 10px;
padding-right: 10px;
border: 1px solid grey;
}
.div-cancel::before {
position: absolute;
top: -4px;
left: 5px;
width: 5px;
height: 5px;
border: 1px solid grey;
border-bottom: 0;
border-right: 0;
background: #fff;
transform: rotate(45deg);
content: '';
}
<div class="div-cancel" id="cancel101">
<span>
<span style="background-color: #FAAB20;">
<i class="fa fa-exclamation" style="width:25px;color:white"></i>
</span> Please type in 'CANCEL' to cancel subscription.
</span>
</div>

Line between three divs css, html

I'm unsure how to tackle what i'm doing.
I'm basically trying to achieve the above. I have a section tag and a list of li tags with a hr tag for the line. They overlap poorly though and don't sit/look as smoothly as i'd like.
Html:
<section class="navigation">
<li class="page_nav--one">One</li>
<hr class="page_nav--line_break" />
<li class="page_nav--two">Two</li>
<li class="page_nav--three">Three</li>
</section>
and my css looks like :
.navigation {
background: #fff;
text-align: center;
margin: 50px 0;
display: block;
.page_nav--line_break {
position: absolute;
display: block;
height: 1px;
top: -14px;
border: 0;
border-top: 1px solid #ccc;
/* margin: 1em 0; */
padding: 0;
width: 400px;
right: 202px;
z-index: 999999;
}
li {
display: inline-block;
list-style: none;
position: relative;
margin: 10px 85px;
}
li:before {
content: '';
height: 16px;
width: 16px;
background-size: 16px 16px;
position: absolute;
top: -23px;
left: 16px;
margin: auto;
cursor: pointer;
pointer-events: none;
}
li:nth-child(1):before {
background: url("trianle_image.png");
}
li:nth-child(2):before {
left: 23px;
background: url("trianle_image.png");
}
li:nth-child(3):before {
left: 35px;
background: url("trianle_image.png");
}
}
Is there a better method/way of achieving what i'm after or am I going about it the correct way?
I would probably use :after pseudo elements.
<div class="diamond"></div>
<div class="diamond"></div>
<div class="diamond"></div>
then the CSS with pseudo elements looks like this:
.diamond {
width:10px;
height:10px;
position:relative:
float:left;
margin-right:100px;
}
.diamond:last-of-type {
margin-right:0;
}
.diamond:after {
content:""
display:block;
width:100px;
height:1px;
background-color:gray;
position:absolute;
top:5px;
left:5px;
}
.diamond:last-of-type:after {
display:none;
}
So the theory is that the after element is your line (like you have) and it is as wide as the margin between the two elements, placed exactly where you need it. Then the last one is hidden.
FIDDLE

span text over the image

i am try to dsiplay span text over the image when mouse hover the div.
i am try this.
html
<div id="some-div">
<a href="#"><img class='round_border type_border' src='http://www.jewsnews.co.il/wp-content/uploads/2013/08/Donald_Duck.gif'/>
<span id="some-element">Dounald
</span></a>
</div>
css look like this
<style>
#some-div{
position:relative
}
#some-element {
width:100px;
height:100px;
border: 1px solid orange;
display: none;
font-size: 10px;
bottom: 0px;
left: 0px;
right: 0px;
text-align: center;
text-transform: uppercase;
position: absolute;
top:0;
left:0;
background:rgba(255,79,50,.5);
color:Black !important;
margin-top:2px;
border:1px solid gray;
-webkit-border-radius: 500px;
-moz-border-radius: 500px;
border-radius: 500px;
}
#some-div:hover #some-element {
display: block;
position: relative;
cursor: pointer;
color:#FFFFFF;
}
a{
position: relative;
}
.type_border {
width: 100px;
height: 100px;
background: white;
position: absolute;
}
.round_border {
float: left;
border:1px solid gray;
-webkit-border-radius: 500px;
-moz-border-radius: 500px;
border-radius: 500px;
background: white;
}
</style>
Add position: absolute to span and position:relative to main div
#some-div{
position:relative
}
#some-element {
width:80px;
border: 1px solid #ccc;
display: none;
font-size: 10px;
bottom: 0px;
left: 0px;
right: 0px;
text-align: center;
text-transform: uppercase;
position: absolute;
top:0;
left:0
}
DEMO
Use Title.
<img class='img' title='Donald Duck' src='http://www.jewsnews.co.il/wp-content/uploads/2013/08/Donald_Duck.gif'/>
If you want text to be displayed on mouse hover image.
You can simply do it by using title attribute of html image element
For ex:
You will be able to see that text when mouse hoveered.
Hope this helps..
Unfortunately as far as i know you cannot insert text on the image.
Workaround for this is to have span in a div which is having background image can work
#some-div{
background-image:url('http://www.jewsnews.co.il/wp-content/uploads/2013/08/Donald_Duck.gif');
background-repeat:no-repeat;
}
check this link http://jsfiddle.net/sy6MG/

CSS/HTML: Tooltip pushing content down

I have a custom CSS Tooltip that when it appears, it pushes the other content down. I know that I need to add position: absolute to get it working right, but I can't seem to figure out where...
HTML:
<p>Fluff</p>
<p>Fluff</p>
<p>Fluff</p>
<p>Fluff</p>
<p>Fluff</p>
<div class="outer">
<a class="tippy" href="">
ICON<img src="" class="icon"/>
</a>
<div class="tooltip">
STUFF<br/>
STUFF<br/>
STUFF<br/>
STUFF<br/>
STUFF<br/>
</div>
</div><!-- Container -->
<p>FluffFluffFluffFluffFluffFluffFluffFluffFluff</p>
<p>FluffFluffFluffFluffFluffFluffFluffFluffFluff</p>
<p>FluffFluffFluffFluffFluffFluffFluffFluffFluff</p>
<p>FluffFluffFluffFluffFluffFluffFluffFluffFluff</p>
CSS:
.outer {
width: 350px;
}
.tippy {
text-decoration: none;
}
a.tippy:hover + div {
display:block;
float: right;
}
.tooltip {
margin-left: 5px;
margin-top: -15px;
padding: 10px;
width: 265px;
height: 110px;
background-color: #ccc;
position: relative;
border: 2px solid #333;
display: none;
}
.tooltip:after, .tooltip:before {
border: solid transparent;
content:' ';
height: 0;
right: 100%;
position: absolute;
width: 0;
}
.tooltip:after {
border-width: 11px;
border-right-color: #ccc;
top: 13px;
}
.tooltip:before {
border-width: 14px;
border-right-color: #333;
top: 10px;
}
Fiddle:
You need to change position:relative to position:absolute in the .tooltip CSS block.
You will also need to modify the CSS for positioning the tooltip due to this change.
If you modify .outer to have position:relative this is as simple as setting .tooltip as
left:55px;
top:-15px;
The resulting CSS (showing only the blocks that have changed):
.outer {
width: 350px;
position:relative;
}
.tooltip {
left: 55px;
top: -15px;
padding: 10px;
width: 265px;
height: 110px;
background-color: #ccc;
position: absolute;
border: 2px solid #333;
display: none;
}
And finally a jsFiddle showing it in action.