I have a design with this effect
I dont care about the font styles or any details, all i am focused right now is on the creating the frame and if possible the button as well. Does anyone know how to do this kind of effect in css?
Here is my very basic html/css code, wont even be of any help. And you can completely modify it if it suits better. BTW i am using bootstrap 3.
/******** The html *********/
<div class="col-md-12 bg-img">
<div>Italy has never been so close</div>
</div>
/******** The css *********/
.bg-img {
display: table;
width: 100%;
height: 100px;
text-align: center;
background: #999 url("http://p1.pichost.me/i/15/1380265.jpg") no-repeat fixed center;
}
.bg-img div {
display: table-cell;
vertical-align: middle;
width:10px;
font-weight:700;
}
I am using a generic image, as it shouldn't make any difference. Here is the fiddle.
https://jsfiddle.net/3aL4xnr8/
You can do this with :after and :before pseudo-elements.
div {
display: table;
margin: 0 auto;
width: 30%;
padding: 20px;
position: relative;
height: 200px;
}
p {
display: table-cell;
vertical-align: middle;
font-size: 40px;
}
div:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 50%;
border-top: 1px solid black;
border-left: 1px solid black;
}
div:after {
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 30%;
height: 50%;
border-bottom: 1px solid black;
border-right: 1px solid black;
}
button {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 50%);
}
<div>
<p>Lorem ipsum dolor sit amet.</p>
<button>Button</button>
</div>
Related
I would like to design a border like below picture. But I am running out of ideas about how to do it.
https://codepen.io/szn0007/pen/VRGPyE
div.about-me h2{
color: #000;
border-bottom: 1px solid #efefef;
width: 20%;
margin: 0 auto;
padding: 20px;
}
THank you in advance.
Luckily with CSS you have access to two pseudo elements on every container. I added the Asterix to one of the pseudo elements :after and the line to another :before.
For example:
.fancy-underline {
position: relative;
display: inline-block;
}
.fancy-underline:before {
content: '';
position: absolute;
top: calc(100% + 10px);
left: 0;
width: 100%;
height: 1px;
background: grey;
}
.fancy-underline:after {
content: '*';
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
background: #fff;
}
<h2 class="fancy-underline">About Me</h2>
try this out:
<div class="about-me">
<h2>About Me</h2>
<p>*</p>
</div>
css:
div.about-me{
width: 100%;
text-align: center;
}
div.about-me h2{
color: #000;
border-bottom: 1px solid #efefef;
width: 20%;
margin: 0 auto;
padding: 20px;
}
p {
font-size: 50px;
transform: translatey(-72px);
}
I am trying to make a border that connects a horizontal line from the right. The sketch below is how it should look like, and I need ideas on how to create this. Thank you! I would greatly appreciate it on anyone who can help me.
Here is a working example.
#example {
position: relative;
}
#example:before {
content: "";
display: block;
width: 100%;
height: 0px;
position: absolute;
top: 50%;
left: 0px;
border-bottom: solid 1px #999;
}
#example span {
position: relative;
display: inline-block;
padding: 5px;
color: #999;
background: #FFF;
border: solid 1px #999;
}
<div id="example">
<span>LATEST PRODUCTS</span>
</div>
<style type="text/css">
.test {
width: 100%;
height: 50px;
background-color: #F0F;
position: relative;
}
.test:before {
width: 100%;
height: 1px;
left: 0;
top: 50%;
content: "";
background-color: #eee;
position: absolute;
}
</style>
<div class="test"></div>
How can I do something like the picture below?
I would like to have an extra thick line to all my h1's but am not quite sure of a best practice to do it.
HTML:
<h1>This is Our Work</h1>
CSS:
h1{
border-bottom: 1px solid #246cb4;
display: inline-block;
}
h1:after {
content: "";
display: block;
border: 1px solid black;
width: 50px;
margin-top: 0px;
position: absolute;
}
Codepen:
You don't need any pseudo elements in this case.
You can draw multiple background images with css3 linear-gradient() with precisely controlled size and positions:
h1 {
background-image: linear-gradient(to right, #246cb4, #246cb4),
linear-gradient(to right, #246cb4, #246cb4);
background-repeat: no-repeat;
background-size: 100% 1px, 50px 3px;
background-position: bottom 2px left, bottom 1px center;
}
h1{
background-image: linear-gradient(to right, #246cb4, #246cb4),
linear-gradient(to right, #246cb4, #246cb4);
background-size: 100% 1px, 50px 3px;
background-repeat: no-repeat;
background-position: bottom 2px left, bottom 1px center;
position: relative;
display: inline-block;
}
<h1>This is Our Work</h1>
You need to add position:relative to the h1 and set margin:0 auto to h1:after
h1 {
border-bottom: 1px solid #0D6CC4;
display: inline-block;
position:relative;
}
h1:after {
content: "";
display: block;
border: 2px solid #0D6CC4;
width: 50px;
margin-top: 0px;
position: absolute;
right: 0;
left:0 ;
bottom:-2px;
margin:0 auto;
}
<h1>This is Our Work</h1>
Try this just with a few tweaks in styling related to position.
h1{
border-bottom: 1px solid #246cb4;
display: inline-block;
position: relative;
}
h1:after {
content: "";
display: block;
border: 2px solid black;
width: 50px;
position: absolute;
left: 0;
right: 0;
margin: auto;
margin-top: -1.5px;
}
<h1>This is Our Work</h1>
used this css
h1:after {
content: "";
display: block;
border: 3px solid black;
width: 50px;
margin-top: 0px;
position: absolute;
right: 0;
left: 0;
margin: 0 auto;
bottom: -3px;
}
h1 {
border-bottom: 1px solid #246cb4;
display: inline-block;
position: relative;
}
You need to position element :after and :before
.main-title{
text-align: center;
}
.inner-title{
position: relative;
font-size: 24px;
padding: 0 0 15px;
margin: 0 0 15px;
text-transform: uppercase;
letter-spacing: 1px;
}
h1:before {
position: absolute;
content: '';
width: 150px;
left: 50%;
margin-left: -75px;
height: 1px;
background: blue;
bottom: 0;
}
h1:after {
position: absolute;
content: '';
width: 50px;
left: 50%;
margin-left: -25px;
height: 3px;
background: blue;
bottom: -1px;
}
<div class="main-title" >
<h1 class="inner-title">Sevices</h1>
</div>
Since you don't know how long every h1 tag will be, i suggest you to translate the element to the center of its parent, like in this example: http://codepen.io/anon/pen/jyMzqN
h1 {
border-bottom: 1px solid #246cb4;
display: inline-block;
position: relative;
}
h1:after {
content: "";
display: block;
position: absolute;
height: 3px;
background-color: black;
width: 50px;
left: 50%;
bottom: -2px;
transform: translateX(-50%);
}
I need to create a separator with text in the middle. By middle I mean both centered horizontally and vertically - there are many examples of this technique using pseudo elements or an extra span in the middle.
Here's some code I would normally use - uses the span method:
h2.centre-line
{
width:40%;
text-align:center;
border-bottom:0.1rem solid #ccc;
line-height:0.1em;
margin:2.5rem 30%;
}
h2.centre-line span
{
background-color:#fff;
padding:0 1rem;
}
<h2 class="centre-line"><span>Text</span></h2>
The problem I have with all of the examples I have found so far is that the text is on a transparent background with margin spacing around it. However what I want to do is place the text in a container with height and keep it centered, like this:
At the moment I've been unable to adapt my code sucessfully and not come across any further suitable examples to follow.
Any ideas?
Your request is a little unclear as it's not stated what this 'separator' is supposed to be separating.
However, vertical & horizontal centering can be achieved by using absolute positioning.
The 'line behind' is achieved by a pseduo-element.
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.wrap {
height: 200px;
position: relative;
background: lightgrey;
margin: 5px;
}
h2.centre-line {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
width: 40%;
transform: translate(-50%, -50%);
}
h2.centre-line:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
top: 50%;
left: 0;
z-index: -1;
background: red;
}
h2.centre-line span {
background-color: lightblue;
padding: 1rem;
display: inline-block;
}
<div class="wrap">
<h2 class="centre-line"><span>Text</span></h2>
</div>
JSfiddle Demo with another wrapper with greater height.
Use an hr? something like this: http://liveweave.com/42IlZQ
hr {
padding: 0;
border: none;
border-top: medium double #333;
color: #333;
text-align: center;
}
hr:after {
content: "ยง";
display: inline-block;
position: relative;
top: -0.7em;
font-size: 1.5em;
padding: 0 0.25em;
background: white;
}
<div class="container">
<hr class="hr-text" data-content="AND">
</div>
<style type="text/css">
.container {
max-width: 50%;
margin: 40px auto;
}
.hr-text {
line-height: 1em;
position: relative;
outline: 0;
border: 0;
color: black;
text-align: center;
height: 1.5em;
opacity: .5;
}
.hr-text:before {
content: '';
background: linear-gradient(to right, transparent, #818078, transparent);
position: absolute;
left: 0;
top: 50%;
width: 100%;
height: 1px;
}
.hr-text:after {
content: attr(data-content);
position: relative;
display: inline-block;
color: black;
padding: 0 .5em;
line-height: 1.5em;
color: #818078;
background-color: #fcfcfa;`enter code here`
}
</style>`enter code here`
I'm trying to figure out how to create a border image for separate divs in the screenshot, yet I can't seem to find a way to do so. Can anyone offer some guidance on how to make these outside border images work?
This is about as close as I can get it. No images required:
.has_tab {
border: 1px solid #e6e6e6;
border-left: none;
width: 33.33%;
height: 300px;
box-sizing: border-box;
display: block;
float: left;
position: relative;
text-align: center;
}
.has_tab:first-child {
border-left: 1px solid #e6e6e6;
}
/* the important bit... */
.has_tab:after {
content: "";
display: block;
width: 10px;
height: 100px;
background: #FFF;
border: 1px solid #e6e6e6;
border-left: none;
border-radius: 0 20px 20px 0;
position: absolute;
top: 50%;
margin-top: -50px;
right: -11px;
}
.has_tab:last-of-type:after {
display: none;
}
<div class="has_tab">Lorem ipsum</div>
<div class="has_tab">Lorem ipsum</div>
<div class="has_tab">Lorem ipsum</div>
Fiddle version
here is how i do it
first you need to cut this image
and then you can use it as background of after element
<div class="borderd-div"></div>
and the css:
.borderd-div{
height: 334px;
width:334px;
border: 1px solid #f1f1f1;
position: relative;
}
.borderd-div:after{
content:" ";
display: block;
position: absolute;
width: 20px;
height: 145px;
right:-19px;
top:83px;
background: url(Djyods1.png) no-repeat 0 0;
}