Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to make two squares before my headings. I know how to make a single square with the before class, but I dont know how to make two that isn't the same width.
What I'm going for is something that looks like this:
You can achieve this by simply a :before as this fiddle does.
HTML
<h1>Reference</h1>
CSS
h1{
font-size: 24px;
color:blue;
}
h1:before{
content:"";
display:inline-block;
margin-right:10px;
height:30px;
width:5px;
border-left:solid 10px blue;
border-right:solid 5px blue;
vertical-align:top;
}
You'll need to also to create the after pseudo element. Let me know if the code below helps.
h1 {
position: relative;
color: #A0CD62;
line-height: 1;
font-weight: 300;
}
h1:before {
content: '';
display: inline-block;
width: 0.25em;
height: 1em;
margin-right: 0.25em;
border-left: 0.5em solid $color-pistashio;
border-right: 0.25em solid $color-pistashio;
}
<h1>Referencer</h1>
.square {background-color:green; width:100px; height:100px;}
.square:before {content:""; background-color:white; position:absolute; width:20px; height:100px; left:50px; }
<div class="square">
</div>
Just change the colour from green to brighter green :D.
Basically what i did there is. Created a big green div with green background. Then using ':before' added white content on the top of it which has the same height as the div.
This should work .
Please , let me know if that helps. :)
I don't think you can do this with only the :before sudo class. Here's a quick pen of it working with both :before and :after. You should be able to monkey about with it to suit your needs. http://codepen.io/sharperwebdev/pen/epgeNQ
.logo {
position: relative;
color: green;
padding: 20px;
left: 50px;
}
.logo:before {
content: "";
position: absolute;
left: -50px;
background-color: green;
width: 30px;
height: 30px;
}
.logo:after {
content: "";
position: absolute;
left: -10px;
background-color: green;
width: 20px;
height: 30px;
}
Why don't you just create an svg of the logo?
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
In the image below there is a arrow head that sticks out of the middle of the bottom edge. How would I be able to create that? I have it marked with the red rectangle.
(source: funkyimg.com)
Green and White appear to be 2 different <section> tags. I can't seem to figure out what to google for, and this is the picture of a website and the actual website doesn't have this already, so can't open it and look up the code.
Use pseudo element after for that the trick is to position:absolute; and borders correctly.
Using top:100%; and border-top for :after adds the down arrow at the bottom of the div.
Using bottom:100%; and border-bottom for :after adds the upward arrow at the top of the div.
.con:after {
content:'';
position: absolute;
top:100%;
left: 50%;
margin-left: -50px;
width: 0;
height: 0;
border-top: solid 50px #e15915;
border-left: solid 50px transparent;
border-right: solid 50px transparent;
}
.con{
width:100%;
height:100px;
background-color:green;
position:relative;
}
<div class="con"></div>
This should help you, it's CSS.
.arrow_box {
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
}
.arrow_box:after, .arrow_box:before {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(136, 183, 213, 0);
border-top-color: #88b7d5;
border-width: 30px;
margin-left: -30px;
}
.arrow
_box:before {
border-color: rgba(194, 225, 245, 0);
border-top-color: #c2e1f5;
border-width: 36px;
margin-left: -36px;
}
You have to set the class in your tag, something like this:
<div class="arrow_box">
<h1 > Something </h1>
</div>
Check fiddle to see how it works: https://jsfiddle.net/kzvrvbzL/1/
Make your element position:relative it's necessary because for arrow you are going to use position:absolute. So relative position will bound its child absolute inside itself. Then make arrow you can use css-triangle-generator. instead of making separate element for arrow you can use before, after pseudo elements.
.section{
height:250px;
position:relative;
background:blue;
margin-bottom:50px;
}
.section:before{
content: '';
position: absolute;
left: 0;
right: 0;
bottom: -30px;
margin: auto;
width: 0;
height: 0;
border-style: solid;
border-width: 30px 50px 0 50px;
border-color: blue transparent transparent transparent;
}
<div class="section"> </div>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have to implement this content separator in my web page using html/css but I cannot find the implementation.
I have the .svg and .png pictures of this flower. Can you show me the steps of doing this, or give me links to some well-explained tutorials. I appreciate any help!
Flexbox and a couple of pseudo-elements make this simple.
span {
display: flex;
width: 100%;
justify-content: center;
align-items: center;
}
span::before,
span::after {
content: '';
flex: 1;
height: 2px;
background: teal;
margin: .5em;
}
<span><img src="http://www.swimmingpoolmosaics.com/images/thumbnails/50/50/variant_image/0/fleur-de-lis-teal.jpg" alt="" /></span>
Related Question
Here's a solution with pseudo element :after
.separator { border-bottom: 1px solid #333; position: relative; margin-top: 30px; }
.separator:after {
content: "";
position: absolute;
left: 50%;
margin-left: -25px; /* half of the image width */
top: -20px;
background: url('http://www.swimmingpoolmosaics.com/images/thumbnails/50/50/variant_image/0/fleur-de-lis-teal.jpg') no-repeat #fff;
width: 50px;
height: 50px;
}
<div class="separator"></div>
A typical HR revisited.
You can use a pseudo to introduce an image on top of it:
hr {
position:relative;
margin:2em 1em;
color:lighgray;
}
hr:before {
content:url(http://i1253.photobucket.com/albums/hh600/fleur-de-lis-xxx/favicon-bright.png);
position:absolute ;
text-align:center;
left:50%;
background:white;
z-index:1;
height:2em;
width:30px;
margin:-15px;
}
<hr/>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using Bootstrap and I am trying to create a similar layout to one used by twitter as seen in the screenshot below.
The Part I am trying to do is where the profile picture is. I am trying to add a div that is positioned over another div and I really have no idea where to start.
I have the nav and the blue container but not sure how to create the div on top like shown.
http://www.bootply.com/v7fKXw63nh
Any ideas?
Try using the relative or absolute CSS positions.
For example, put the following code at the bottom of your example.
<div style="position: absolute;
left: 150px;
top: 120px;
width: 75px;
height: 75px;
background-color: #666"></div>
#profileWrapper {
width: 100%;
height: 150px;
background: lightgray;
position: relative;
}
#topHeader {
position: absolute;
top: 5px;
left: 5px;
right: 5px;
bottom: 5px;
background: lightblue;
border-radius: 10px;
}
#profiler {
width: 100px;
height: 100px;
background: lightblue;
border: 5px solid lightgray;
border-radius: 5px;
position: absolute;
bottom: -50px;
left: 50px;
text-align: center;
}
.fa {
color: lightgray;
display: table-cell;
height: 200px;
vertical-align: middle;
}
.fa:hover {
color: white;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<div id="profileWrapper">
<div id="topHeader">
<div id="profiler"><span class="fa fa-camera fa-3x"></span>
</div>
</div>
</div>
Fiddle link (Don't forget to resize the demo section in fiddle)
HTML:
<div class="col-sm-12">
<div class="col-sm-2 col-xs-offset-1"></div>
</div>
CSS(used in the demo):
.col-sm-12{
height:100px;
background:#33CCFF ;
}
.col-sm-2{
height:150px;
background:#33CCFF;
margin-top:50px;
border: 4px solid white;
border-radius:5px;
}
I'm trying to make an hr with two colors on it, one dark red on the bottom and one orange on the top. An image is attached that gives an example of what I'm trying for. Is there any way to do this using pure CSS?
EDIT: If not, is there a way to set an hr to be an image? Like a png? Something that will stretch for different sizes?
Use CSS with 2 borders like so:
hr {
border-top: 1px solid gray;
border-bottom: 1px solid white;
}
Example in JSFiddle.
And to mimic what you have in your picture with text floating on top of the HR, you can do something like this JSFiddle.
Another solution could be to just simply use a CSS gradient. Like so:
hr {
border: 0;
height: 1px;
background: #1e5799;
background: linear-gradient(to right, #1e5799 50%,#7db9e8 50%);
}
so if i understand correctly.. u want one hr..with lets say 1px height of blue and another 1px height of red sitting on top of each other..
u can do this with pure css, by using pseudo classes.
hr{
position:relative;
height:1px;
background-color:red;
}
hr:before {
position:absolute;
content : ' ';
left:0;
right:0;
height:1px;
top:-1px;
background-color:blue;
}
You don't need to use hr just a single element (Div) with Pseudo-elements like this:
:root {
background-color: red;
text-align: center
}
:root:hover {
background-color: orange;
}
div {
position: relative;
width: 40px;
display: inline-block;
font-style: italic
}
div:before, div:after{
content: '';
position: absolute;
width: 100px;
height: 1px;
background: black;
top: 50%;
border-radius: 4px;
box-shadow: 0 1px 1px white;
}
div:before{
left: -100px;
}
div:after{
right: -100px;
}
<div>or</div>
I'm trying to insert a text with the upper side of a box using CSS, but I can't come up with anything to make it happen. this is my code so far:
.boxed{
border: 1px solid grey;
width: 300px;
height: 180px;
}
and this is what I want to do:
how do i insert a text in the upper border of a box?
*im already done with this thanks guys. but my problem now is putting pagination on tabs. can u help me? the rest of the code is in here:
http://jsfiddle.net/3y539gvq/
Set your box to relative positioning and position the label using absolute positioning. Also, I'd recommend setting the background of your container, and inheriting the background in the label CSS to keep the two consistent.
.boxed {
position: relative;
background: white;
border: 1px solid grey;
width: 300px;
height: 180px;
}
.label {
background: inherit;
padding: 0 5px;
position: absolute;
left: 5px;
top: -10px;
}
<div class="boxed">
<span class="label">General Information</span>
</div>
DEMO: http://jsfiddle.net/b7a29fsd/1/
You can use:
.boxed {
... your existing styles ...
position:relative;
}
.boxed:after {
position:absolute;
top:-5px;
left:15px;
padding:3px;
content: "your label text";
background-color: (something to cover up the border underneath)
}
You can put a text within the div you have like so:
<div>
<p> Some text </p>
</div>
CSS:
.boxed{
border: 1px solid grey;
width: 300px;
height: 180px;
position:absolute;
}
.boxed p{
position:relative;
top:-28px;
left:5px;
z-index:1;
background-color:white;
width:80px;
}
}
Example here.