How to create the pop up box as shown below in image with pure css
Here is what I have made with position:absolute which works fine but what I am trying to get is, is it possible to do only with one div by using :after or :before pseudo classes?
.pop{
background:#333;
display:inline-block;
width:250px;
height:120px;
border-radius:8px;
position:relative;
margin-top:25px
}
span{
position:absolute;
left:0;
top:-20px;
color:white;
display:inline-block;
border-radius:8px 8px 0 0;
background:#333;
padding:6px;
width:100px
}
Fiddle
This one is not much flexible, but does thing without additional markup, using pseudo element ::before.
.pop {
background: #333;
width: 250px;
height: 120px;
border-radius: 8px;
display: inline-block;
}
.pop::before {
content: "Pop up head";
display: block;
width: 90px;
background: #333;
border-radius: 8px;
padding: 3px;
margin-top: -14px;
text-align: center;
color: white;
}
<div class="pop"></div>
If I understood your question correctly this is what you need http://jsfiddle.net/slash197/Cup5Y/15/
HTML
<div class="holder">
<div class="header">Header</div>
<div class="pop">asd asd asd </div>
</div>
CSS
.holder {
position: relative;
width: 250px;
height: 140px;
}
.header {
position: absolute;
top: 0px;
left: 0px;
height: 20px;
background:#333;
color: #ffffff;
border-top-left-radius:8px;
border-top-right-radius:8px;
padding: 0px 10px;
}
.pop{
position: absolute;
top: 20px;
left: 0px;
background:#333;
color: #ffffff;
display:inline-block;
width:250px;
height:120px;
padding: 10px;
border-top-right-radius:8px;
border-bottom-left-radius:8px;
border-bottom-right-radius:8px;
}
First you need 2 divs, one for the "header" and one for the "content"
see my example http://jsfiddle.net/Cup5Y/13/
<div class="pop">
<div class="head">
Title
</div>
<div class="content">
</div>
</div>
Related
I have two divs that overlap horizontally. My issue is that one of the divs contain text and a href link which is not working.
You can see the code I have here
https://jsfiddle.net/jayreis/w7regdcr/
.postwrapper
{
margin:auto;
width:80%;
display:block;
padding-bottom:15px;
}
.imageDiv
{
margin-left: 100px;
background: #fff;
display: block;
width: 445px;
height: 220px;
padding: 10px;
border-radius: 2px 2px 2px 2px;
}
.imageDiv img
{
width:600px;
height:400px;
}
.textboxDiv
{
position:relative;
bottom:145px;
left:470px;
zoom: 1; /*to fix the has layout bug in IE older version*/
filter: alpha(opacity=50);
opacity: 0.9;
background-color:#ffffff;
text-align:center;
}
.textboxDiv:after
{
content:'';
position: absolute;
top: -15px;
left: -15px;
right: -15px;
bottom: -15px;
border: #dddddd 2px solid
}
.readarticle
{
text-decoration:none;
border-top: 1px solid #a61531;
float:left;
color:#000000;
z-index: 99999;
}
<div class="postwrapper">
<div class="imageDiv">
<img src="http://www.ccc.com/media/post/image/6/0/600x400.png" />
</div>
<div class="imageDiv textboxDiv">
<p style="color:#000000; margin-auto; width:35%; margin-left:-10px; padding-bottom:10px">date here
</p>
<h4>the title</h4>
<p style="color:#000000">desc here</p>
<br />
<p><a href="http://www.ccc.com" title="test" class='readarticle'>READ ARTICLE</a></p>
</div>
</div>
So if you look at the css if I change the position: absolute; to be position: relative; in the class style .textboxDiv:after the link then works but I loose the border style I need around the box.
Any suggestions how I can keep the style yet make the links work in the textboxDiv ??
.readarticle is not positioned, so the z-index won't work. Simply add position: relative; and it'll work.
.readarticle
{
text-decoration:none;
border-top: 1px solid #a61531;
float:left;
color:#000000;
z-index: 99999;
+ position: relative;
}
MDN Documentation: Z-Index
i have a problem like this.
#relative{
position:relative;
width:100%;
height:100%;
text-align:center;
}
button{
margin:10px auto;
width:200px;
height:auto;
border:1px solid;
border-radius:5px;
}
#absolute{
position: absolute;
top: 0;
left:0;
height: 250px;
width: 100%;
border: solid 1px #000000;
color: blue;
font-weight: bold;
padding-top: 60px;
/*opacity:0;*/
}
button:hover{
background-color:#eed5a4;
}
<div id="relative">
<button>
Hover me if you can.
</button>
<div id="absolute">
Absolute its me dude!!<br>
If me >> opacity:0<br>
Button still cant be hover.
</div>
</div>
Any solution for this, and i dont know to use the good english language
Note : button keep like this, do not change the position absolute too.
- my english so bad :(
Add position:relative; and a higher z-index than that of the #absolute div to the button itself, like so:
HTML
<button id="relative-button">Hover me if you can.</button>
CSS
#absolute { z-index:1 }
#relative-button { position:relative; z-index:2 }
replace button css like this
button {
border: 1px solid;
border-radius: 5px;
height: auto;
margin: 10px auto;
position: relative; /* newly added */
width: 200px;
z-index: 9; /* newly added */
}
Thanks #daniel lisik, you are awesome people. Extraordinary
#relative{
position:relative;
width:100%;
height:100%;
text-align:center;
}
button{
position:relative;
z-index:5;
margin:10px auto;
width:200px;
height:auto;
border:1px solid;
border-radius:5px;
}
#absolute{
position: absolute;
z-index:1;
top: 0;
left:0;
height: 250px;
width: 100%;
border: solid 1px #000000;
color: blue;
font-weight: bold;
padding-top: 60px;
/*opacity:0;*/
}
button:hover{
background-color:#eed5a4;
}
<div id="relative">
<button>
Hover me if you can.
</button>
<div id="absolute">
Absolute its me dude!!<br>
If me >> opacity:0<br>
Button still cant be hover.
</div>
</div>
I have an image I would like to display as a circle with (border-radius:50%) and on the same line I would like to have some text with a set width and background. I would not like to hard code any values. What is the best way of accomplishing this?
Here is a picture
fiddle
<div class="header">
<img class="i" src="http://www.planwallpaper.com/static/images/colorful-triangles-background_yB0qTG6.jpg"/>
<p class="headingText">Hello</p>
</div>
.i {
width: 80px;
height: 80px;
border-radius: 50%;
}
.headingText {
color: white;
background: black;
display: inline-block;
width: 350px;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
}
You could try something like this:
.header
{
padding-top:26px;
padding-left:40px;
position:relative;
}
.i
{
position:absolute;
width:80px;
height:80px;
border-radius:50%;
top:0;
left:0;
}
.headingText
{
color:white;
background:black;
display:inline-block;
width:350px;
padding-top:10px;
padding-bottom:10px;
text-align:center;
}
Using pseudo-classes and absolute positioning you can get the effect you want.
The below answer uses your existing HTML so you don't have to change any of that and just changes your CSS.
You can add some more padding to the text to make it a bit more spaced out if required and the background should sort itself out.
.header {
position: relative;
display: inline-block;
margin: 30px;
overflow: visible;
}
.header img.i {
width: 80px;
height: 80px;
border-radius: 50%;
position: absolute;
bottom: 16px;
left: -40px;
z-index: 1;
overflow: hidden;
border: 3px solid black;
}
.header p.headingText {
padding: 16px 32px 16px 80px;
color: black;
border: 3px solid black;
}
<div class="header">
<img class="i" src="http://www.planwallpaper.com/static/images/colorful-triangles-background_yB0qTG6.jpg" />
<p class="headingText">Hello</p>
</div>
Just add position: absolute in i class then control the margin of headingtext:
HTML:
<div class="header">
<img class="i" src="http://www.planwallpaper.com/static/images/colorful-triangles-background_yB0qTG6.jpg"/>
<p class="headingText">Hello</p>
</div>
CSS:
.i
{
width:80px;
height:80px;
border-radius:50%;
position: absolute;
}
.headingText
{
color:white;
background:black;
display:inline-block;
width:350px;
padding-top:10px;
padding-bottom:10px;
text-align:center;
margin: 40px 0 0 37px;
}
FIDDLE
use a block element instead with a negative margin to the top (half circle size - half of the padding) and a margin to the left (half circle size). Just change:
.headingText {
/*display: inline-block;*/
display: block;
margin-top: -45px;
margin-left: 40px;
}
Example fiddle: https://jsfiddle.net/c67dchhv/
just simple make .header class position:relative; if you want to define any height and width you can, .i class position:absolute; give margin on .headingtext class https://jsfiddle.net/hamzanisar/aphzeyyt/ maybe it will helpful for you.
I want to draw this shape using HTML and CSS:
My problem is how to draw the 2 lines in left and in the right of green rectangle.
This is my attempt:
.c{
width: 225px;
float: left;
padding: 13px;
margin: 5px;
border-width:2px;
border-color:#777;
border-style:solid;
text-align: center;
border-radius: 30px;
}
.c .cadre{
background: #60b000;
width: 20px;
height: 20px;
border-radius: 3px;
margin: 10px auto 0px;
}
.c .cadre .num{
font-size: 17px;
margin-right: 2px;
color: white;
}
<h3> Commment ça marche</h3>
<div class="c">
<h3> titre1 </h3>
The element selector selects elements based on the element name.
<div class="cadre"><span class="num">1</span></div>
</div>
Thank you for help in advance.
Use a pseudo-element like :before, also move the styles from cadre to style the span num.
Try this:
.c {
width: 225px;
float: left;
padding: 13px;
margin: 5px;
border-width: 2px;
border-color: #777;
border-style: solid;
text-align: center;
border-radius: 30px;
}
.c .cadre {
position:relative;
}
.c .cadre .num {
background: #60b000;
border-radius: 3px;
margin: 10px auto 0px;
width: 20px;
height: 20px;
display:block;
font-size: 17px;
color: white;
position:relative;
z-index:10;
}
.c .cadre:before {
content:" ";
width:80%;
position:absolute;
height:5px;
left:50%;
top:50%;
transform:translate(-50%, -50%);
background:orange;
}
<h3> Commment ça marche</h3>
<div class="c">
<h3> titre1 </h3>
The element selector selects elements based on the element name.
<div class="cadre"><span class="num">1</span>
</div>
</div>
im using this CSS for my website footer:
what would be the best way to make it display in the centre of the page. my website is responsive so they automatically go underneath each other when the screen is made smaller but when the screen is larger they are more to the left than the right.
i have created a fiddle here so you can also see the html:http://jsfiddle.net/x4A4B/
any help would be much appreciated
#footer {
width:100%;
min-height:500px;
position:relative;
bottom:0;
left:0;
border-top:4px solid #F36F25;
background-color:#666666;
color:#EEEEEE;
}
#footer-inner {
width:80%;
margin:0 auto 0 auto;
height:inherit;
}
#footer-top {
width:100%;
padding-top:10px;
border-bottom:2px #EEEEEE solid;
display:block;
}
#footer-left {
width: 290px;
display:inline-block;
padding: 5px 15px;
border-right:1px #EEEEEE solid;
vertical-align:top;
}
#footer-middle {
width: 294px; /* Account for margins + border values */
display:inline-block;
padding: 5px 15px;
margin: 0px 5px 5px 5px;
border-right:1px #EEEEEE solid;
vertical-align:top;
}
#footer-right {
width: 270px;
padding: 5px 15px;
display:inline-block;
vertical-align:top;
}
#footer-bottom {
margin-top:5px;
padding: 15px 15px;
font-size:12px;
}
are you talking about your Copyright label?
if I understood correctly, you need text-align:center; in footer-bottom as in
#footer-bottom {
margin-top:5px;
padding: 15px 15px;
font-size:12px;
text-align:center;
}
I think you'll need something like this regarding lay-out:
HTML:
<div class="wrapper">
<div class="left">
Content goes here
</div>
<div class="middle">
Content goes here
</div>
<div class="right">
Content goes here
</div>
</div>
CSS:
.wrapper{
position: relative;
float: left;
left: 20.00%;
width: 60.00%;
}
.left{
position: relative;
float: left;
left: 0%;
width: 32.00%;
}
.middle{
position: relative;
float: left;
left: 1.50%;
width: 32.00%;
}
.right{
position: relative;
float: right;
right: 0%;
width: 33.00%;
}
Of course, you'll have to fill the structure with your content, and modify the margins to completely suit your needs, but I think you'll manage to do that. This example is just to get the idea.
See it in action here: JSFiddle