I'm trying to write CSS to get this design
Here's my CSS so far:
.exp {
font-weight: 300;
display: inline-block;
padding-bottom: 15px;
position: relative;
margin-bottom: 30px;
font-style: italic;
}
.exp:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0;
left: 0%;
border-bottom: 1px solid #219b65;
}
HTML:
<h1 class="exp">Experience</h1>
And here's the JSFIDDLE
Any idea how to go about doing this? I did it a few years ago but couldn't get it to work again!
Here's a complete answer for you. Adjust widths to you needs.
.FromTheFounder {
font-weight: 300;
display: inline-block;
padding-bottom: 15px;
position: relative;
margin-bottom: 30px;
font-style: italic;
}
.FromTheFounder:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 13px;
left: 0%;
border-bottom: 1px solid #219b65;
z-index: 1;
}
.FromTheFounder:after {
content: "";
position: absolute;
width: 300%;
height: 1px;
bottom: 13px;
left: 0%;
border-bottom: 1px solid #ccc;
}
https://jsfiddle.net/vjhg7mna/
Brett's answer will work perfectly if you know the width of your container, or want the underline to only span a certain width. If you want the underline to fill the available space, you'll need two elements - one for the full-width underline, and the other for the highlighted underline.
This would also be possible with one element using ::after in place of exp-title and setting the content property to "Experience", but that's not very user-friendly.
Note that I've made the underline significantly fatter (5px) so the effect is more obvious.
.exp {
position: relative;
font-style: italic;
border-bottom: 5px solid #ccc;
}
.exp-title {
display: inline-block;
border-bottom: 5px solid #f00;
font-weight: 300;
padding-bottom: 15px;
margin-bottom: -5px;
}
<h1 class="exp">
<span class="exp-title">Experience</span>
</h1>
For what it's worth, another option here is to use a linear-gradient background on a pseudo element, instead of an actual border.
The disadvantage here is that this option doesn't have the flexibility to automatically match the width of any arbitrary length of text in your h1. But then again, if you've got several headers, and you want the highlighted portion of the underline to be the same width for all of them, regardless of text length, this may be the way to go.
.some-container {
position: relative;
padding-bottom: 15px;
}
.exp {
font-weight: 300;
display: inline-block;
margin-bottom: 0;
font-style: italic;
}
.some-container::after {
content: "";
display: block;
position: absolute;
width: 100%;
height: 3px;
bottom: 0;
left: 0%;
background-image: linear-gradient(to right, steelblue, steelblue 25%, lightgray 25%, lightgray);
}
<div class="some-container">
<h1 class="exp">Experience</h1>
</div>
Related
I am working on a new font icon library, and trying to get a desired result that looks like below using only CSS. I can get the single color backgrounds working with css without any issues, but trying to find the best way to do the angled second background layer in a way that will keep ratio based on the font-size used.
Here is my current wip css.
.aw-#{$app_name}:before {
content: $app_code;
}
.aw-#{$app_name}-app:before {
content: $app_code;
position: relative;
border-top-left-radius: 1.25rem;
border-top-right-radius: 1.25rem;
border-bottom-right-radius: 1.25rem;
position: relative;
}
.bg-app-black {
position: relative !important;
}
.bg-app-black:before {
position: absolute;
content: "";
display:block;
width: 5rem;
height: 5rem;
border-radius: 1.25rem;
background-color: #222;
display:inline-block;
background: -0.1rem -0.1rem 0 1.5rem #000;
transform: rotate(-20deg);
}
Here is the html:
<div class="bg-app-black"><i class="aw-actions-app bg-development-app"></i></div>
Here is the results I am getting, and it doesn't scale as the font size changes.
To do it, you need to know that em unit is equal to the computed value of the font-size property of the element on which it is used. And, by default, descendants inherit font-size.
b {
position: relative;
display:inline-block;
font-size: 3rem;
}
b:before {
content: 'N';
position: relative; z-index:1;
display: inline-flex;
font-size: .8em;
width: 1.25em;
height: 1.25em;
border-radius: .3125em .3125em .3125em 0;
margin: .33em 0 0 .33em;
color: #fff;
background: #db2828;
justify-content: center;
align-items: center;
}
b:after {
content: "";
position: absolute;
bottom: 0;
right: 0;
width: 1em;
height: 1em;
border-radius: .25em;
background: #222;
transform: rotateZ(-20deg);
transform-origin: 0 100%;
}
<b></b>
<b style="font-size:5em"></b>
<b style="font-size:24px"></b>
I have a div :
<div class="titre_section" id="identity_section_titre_section">Identité du déclarant</div>
i need to put a background outside the div to apply a bigger height than the div
for the moment i have :
.titre_section {
position: relative;
#include media-breakpoint-down(sm) {
top: -2em;
}
top: -5em;
left: -2em;
padding-left: 20px;
font-family: $titre_section-font-family;
font-style: normal;
font-weight: bold;
font-size: 22px;
line-height: 25px;
letter-spacing: 0.25px;
color: $form-dark-color;
background: url("/custom/images/titre_section_rectangle.png") no-repeat;
background-size: contain;
}
here the result :
i tried to make this in order to modify the height of the background :
.titre_section::before{
content: "";
background: url("/custom/images/titre_section_rectangle.png") no-repeat;
background-size: contain;
}
but it's not working i don't see the background.
the result need to be like. i can't edit the html because we use zend form system
Here's a quick example using position: absolute to ensure that the background doesn't take up space, and z-index to ensure that the background is behind the content.
.section {
position: relative;
}
.section:before {
content: '';
position: absolute;
width: 400px;
height: 100px;
background: red;
z-index: -1;
}
<div class="section">Identité du déclarant</div>
<div>Lorem ipsum</div>
I have used :pseudo element to add the border effect in the left
.titre_section {
position: relative;
padding: 0px 0 10px 35px;
border-bottom: 1px solid #d2cfc7;
font-weight:bold;
margin-bottom:20px
}
.titre_section:before {
content: '';
position: absolute;
top: 0;
bottom: -20px;
width: 2px;
background: #bb8f29;
left: 20px;
}
<div class="titre_section" id="identity_section_titre_section">Identité du déclarant</div>
I'm requesting your help with a .css hr class
I'm trying to figure out how to make a double border like this:
Here's what i did:
hr.style15 {
border-top: 4px double black;
}
hr.style15:after {
content: 'SHIPPING INFO';
display: inline-block;
position: relative;
top: -15px;
left: 40px;
padding: 0 10px;
background: #f0f0f0;
color: #8c8b8b;
font-size: 18px;
}
My questions are:
1) How do I get rid of the inline-block below the 2 lines? I've tried by deleting the inline-block sentence but it doesn't work.
2) Can I add font-family and font size to this?
3) Is it possible to increase the space between the 2 lines without increasing the width?
Basically I believe I'd do it differently. Using both :after and :before for the lines will help you drastically on putting a text on top of it.
So I prepared this CodePen for you. Basically what I did was using an :after and a :before (as I told you before) for the border-lines and after that I added a span with a background-color (in this case white) on top of the border-lines (look at the z-index).
.container {
width: 800px;
position: relative;
}
.double-bar {
&:after {
content: "";
border-bottom: 1px solid black;
width: 100%;
position: absolute;
top: 9px;
left: 0;
z-index: 1;
}
&:before {
content: "";
border-bottom: 1px solid black;
width: 100%;
position: absolute;
top: 13px;
left: 0;
z-index: 1;
}
span {
z-index: 2;
position: relative;
background-color: white;
left: 40px;
padding: 0 7.5px;
text-transform: uppercase;
font-weight: 600;
font-size: 20px;
}
}
You can see a demo of this.
I hope this helps!
Please have a check with this:-
HTML
<h1 class="title"><span>Shipping info</span></h1>
CSS
h1.title {
margin-top: 0;
position: relative;
}
h1.title:before {
content: "";
display: block;
border-top: solid 1px black;
width: 100%;
height: 2px;
position: absolute;
top: 50%;
z-index: 1;
border-bottom: 1px solid #000;
}
h1.title span {
background: #fff;
padding: 0 20px;
position: relative;
z-index: 5;
margin-left: 50px;
}
I am trying to make a ribbon type header for a website I am working on but I am struggling to get the text to adapt well to a smaller resolution.
Is there a way I can make the text responsive, or flow to a double line on smaller screens?
I have put the code into JS fiddle to show what I am using here.
h3.ribbon {
background: #c3d5d8;
margin-top: 0px !important;
margin-left: -30px;
padding-left: 20px;
color: #fff;
border-bottom: 40px solid #c3d5d8;
border-right: 20px solid #fff;
height: 0px;
line-height: 40px;
font-size: 18px !important;
font-family: 'ProximaNovaThin';
text-rendering: optimizeLegibility !important;
-webkit-font-smoothing: antialiased !important;
font-weight: bold;}
You could use a skew'd pseudo element for this, allowing for the text to wrap if need be.
.title {
display: inline-block;
width: 70%;
min-height: 50px;
line-height: 50px;
background: lightgray;
position: relative;
}
.title:before {
content: "";
position: absolute;
height: 100%;
min-width: 120px;
width: 40%;
left: 80%;
background: lightgray;
transform: skewX(45deg);
z-index: -1;
}
<div class="title">this is a long title............................a really long title! Like a super long title that should require a second line!</div>
I'm having a nightmare, I have a very simple premise, it works fine when it's occupying one line...
http://imgur.com/dKtkJQs,vFJvW7c#0 <-- it should look like this
However, if it's in a narrower column and spans over two lines, the + and the > just don't want to vertical center align.
http://imgur.com/dKtkJQs,vFJvW7c#1 <-- This is how it looks when over two lines, not my desired result
For some reason, the fiddle has the :before overlapping when it doesn't in my code. But my point mainly is, how do I get the + and > to vertically align in the middle? I think I've torn all my hair out.
HTML code
CREATE 1st UNIT
CSS code
body {
font-family: 'Open Sans', 'sans-serif';
padding: 20px;
padding-top: 50px;
background-color: #CCCCCC;
font-weight: 100;
font-size: 12px;
text-align: center;
}
.bttn{
position: relative;
display: block;
margin-top: 3px;
padding: 5px 10px 5px 40px;
background: #1E90FF;
font-size: 18px;
color: #ffffff;
font-weight: 700;
text-decoration: none;
}
.bttn::before{
position: absolute;
top: 0;
left: 0;
bottom: 0;
margin: auto;
height: 100%;
padding: 5px 10px 5px 10px;
content: "+";
background: #104E8B;
font-size: 18px;
font-weight: 500;
}
.bttn:after{
position: absolute;
top: 0;
right: 0;
bottom: 0;
height: 100%;
padding: 5px 10px 5px 10px;
float: right;
content: ">";
font-weight: 500;
}
.create, .create::before, .create::after{
font-size: 10px;
}
.create{
padding-left: 20px;
}
.create::before, .create-coffer::after{
padding: 5px 5px 5px 5px;
}
Vertical alignment is difficult when dealing with responsive elements. My suggestion would be that the 'plus' and 'arrow' icons be background-images of the psuedo elements. That way you can align them to the exact center.
Otherwise, you could align the elements vertically using the translate trick. But then you'd also need the dark blue background to be an absolute positioned span element.
top: 50%;
transform: translateY(-50%);