solid text on transparent div on image - html

I am trying to reproduce this image, with HTML and CSS, but I'm not sure how to place solid images on translucent divs on top of an image. There's one up top and on bottom. And I need a table of these.
http://dl.dropbox.com/u/17949100/house.png
Response to comment: <table> is my lazy way of forcing all the divs to be the same width (and the image). I guess I need to take the text out of the divs and place them, which I also had a hard time doing. Then I worried if use resizes the browser.
Here's what I got so far on jsFiddle. Here's the HTML code:
<table><tr><td>
<img src="http://dl.dropbox.com/u/17949100/samplehouse.png">
<div class="address"><p class="address">804 Rolfe</p></div>
<div class='desc'>
<span class='l'>2 Bedrooms</span>
<span class='r'>$2100</span>
</div>
</td></tr></table>
Here's the CSS file:
div.address {
width:100%;
height:20px;
background-color:#000000;
opacity:0.5;
}
span.l{
width:50%;
font-family:Helvetica;
color:#FFFFFF;
text-align:center;
font-size:75%;
float:left;
margin-top:0px;
}
span.r{
width:50%;
font-family:Helvetica;
color:#FFFFFF;
text-align:center;
font-size:75%;
float:right;
margin-top:0px;
}
div.desc {
width:100%;
height:20px;
background-color:#000000;
opacity:0.5;
}
p.address{
font-family:Helvetica;
height:20px;
opacity:1;
color:#FFFFFF;
text-align:center;
}

The fiddle with markup cleaned and css refactored: http://jsfiddle.net/32szC/4/
Anyway take into serious consideration the suggestion to not use tables for layout purpose: so I made the css working even if you choose to remove the table structure at all using display: inline-block on the .wrapper element (see http://jsfiddle.net/32szC/7/)
HTML
<table>
<tr><td>
<div class="wrapper">
<img src="http://dl.dropbox.com/u/17949100/samplehouse.png" />
<div class="address"><span class="address">804 Rolfe</span></div>
<div class='desc'><span>2 Bedrooms</span><span>$2100</span></div>
</div>
</td></tr></table>
CSS
.wrapper {
position: relative;
height: 100%;
}
.wrapper div {
position: absolute;
z-index: 1;
left: 0;
width: 100%;
background: rgba(0,0,0, .75);
height:20px;
}
div.address { top: 0; }
div.desc { bottom: 0; }
span {
font-family: Helvetica;
text-align:center;
font-size:75%;
color: #fff;
height: 20px;
line-height:20px;
}
.address span {
display: block;
}
.desc span {
width:50%;
float: left;
}
.desc span + span {
float:right;
}

Here's my interpretation of what you should be doing:
http://jsfiddle.net/32szC/8/
HTML:
<div class="product">
<img src="http://dl.dropbox.com/u/17949100/samplehouse.png">
<span class="address">804 Rolfe</span>
<div class='desc'>
<span class='left'>2 Bedrooms</span>
<span class='right'>$2100</span>
</div>
</div>
CSS:
.product {
width: 272px;
height: 220px;
position: relative;
}
.product img {
position: relative;
z-index:1;
}
.address, .desc {
display: block;
width: 252px; /* 272px */
padding: 5px 10px;
position: absolute;
top: 0;
left: 0;
z-index: 2;
background-color: rgba( 0, 0, 0, 0.5);
color: #fff;
}
.desc {
top: auto;
bottom: 0;
overflow: hidden;
}
.desc .left {
float: left;
}
.desc .right {
float: right;
}

Here's my attempt, it includes the shadow border around the image: http://jsfiddle.net/katychuang/2R3hk/
Removed tables to use div. The outer class is "item"
<div class="item">
<div class="address">
<span>804 Rolfe</span>
</div>
<img src="http://dl.dropbox.com/u/17949100/samplehouse.png">
<div class='desc'><span class='l'>2 Bedrooms</span><span class='r'>$2100</span></div>
</div>
And the CSS. It is good to specify the individual widths for .item and .item img, to get them to line up rather than using 100%
.address {
height:20px;
width:inherit;
background: rgba(0, 0, 0, 0.70);
font-family:Helvetica;
color:#FFFFFF;
text-align:center;
z-index:500;
position:absolute;
top:0px;
left:0px;
padding-top:5px;
}
span.l{
width:50%;
font-family:Helvetica;
color:#FFFFFF;
text-align:center;
font-size:75%;
float:left;
}
span.r{
width:50%;
font-family:Helvetica;
color:#FFFFFF;
text-align:center;
font-size:75%;
float:right;
}
.desc {
width: inherit;
background: rgba(0, 0, 0, 0.70);
height: 20px;
z-index: 500;
position: absolute;
bottom: 0px;
left: 0px;
padding-bottom: 5px;
}
.item img {width:250px}
.item {
position:relative;
width: 250px;
margin: auto;
padding: 0px;
-moz-box-shadow: 0px 0px 1em rgba(0, 0, 0, 0.9); /* FF3.5+ */
-webkit-box-shadow: 0px 0px 1em rgba(0, 0, 0, 0.9); /* Saf3.0+, Chrome */
box-shadow: 0px 0px 1em rgba(0, 0, 0, 0.9); /* Opera 10.5, IE 9.0 */
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=10px, OffY=10px, Color='#888'); /* IE6,IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=10px, OffY=10px, Color='#888')"; /* IE8 */
}
body {background-color:#EEEEEE;}

Looks like you just need some negative margins. I would place the address above the image and the description below it. Then something as simple as margin-bottom: -20px will overlap the address over the image.
I made the appropriate changes here jsFiddle

Related

Why modal-backdrop overlapped my popup modal even set !important and z-index? How to fix it?

I had a successful message popup. Now I want to add a semi-transparent backdrop layer underneath with rgba(0,0,0,0.5), that I used CSS ::before. But the backdrop ::before { rgba(0,0,0,0.5) } seems to overlap my green popup, even when I set z-index and background: !important for the popup.
Here's the code I've tried
.alertMessageModal{ width:auto; height:auto; border-radius:10px; display:inline-block; position:fixed; top:20px; right:25px; color:#fff; padding:10px 15px; padding-bottom:15px; z-index:100; background:green !important;}
.alertMessageModal::before{content:''; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0, 0, 0, 0.5); z-index:-100;}
.alertMessageModal .modal-title{ font-size:15px; float:left; line-height:18px;}
.alertMessageModal .close{ float:right; margin-left:10px; line-height: 15px; color:#fff;}
<div class="alertMessageModal bg-success">
<h4 class="modal-title">Your message has been successfully sent</h4>
<button type="button" class="close">×</button>
</div>
You need to wrap the modal's content inside another extra wrapper div .modal-content. The example from w3school.
Your code doesn't work as expected because z index not working with fixed positioning
Here's the working code, I changed a few lines of code from yours:
/* renamed from .alertMessageModel::before */
.alertMessageModal {
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: -100;
}
/* renamed from .alertMessageModal */
.modal-content {
width: auto;
height: auto;
border-radius: 10px;
display: inline-block;
position: fixed;
top: 20px;
right: 25px;
color: #fff;
padding: 10px 15px;
padding-bottom: 15px;
z-index: 100;
background: green !important;
}
.alertMessageModal .modal-title {
font-size: 15px;
float: left;
line-height: 18px;
}
.alertMessageModal .close {
float: right;
margin-left: 10px;
line-height: 15px;
color: #fff;
}
<div class="alertMessageModal bg-success">
<!-- added an extra div -->
<div class="modal-content">
<h4 class="modal-title">Your message has been successfully sent</h4>
<button type="button" class="close">×</button>
</div>
</div>

href link not working on overlapping divs

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

How to make a css 'snail'?

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.

CSS :hover command is not working

So i am creating a test webpage but having trouble with getting the :hover command to work properly. No matter what i have tried to do from research seems to work so i am in need of some help.
I am trying to blur out a image and then have text fade in, but i got stuck at having the image blur out using webkit filters. So i stripped it back and just tried changing one colour to another, and even that did not work. What Seems to be the problem?
HTML
#MenuHome {
top:-20px;
right:130px ;
font-size: 40px;
}
#Checkout {
left:190px
}
body {
height:1100px;
}
/*Content*/
#Content {
position:absolute;
top:100px;
width:1100px;
height: 2000px ;
left:50% ;
margin-left: -550px;
background-color: #ecf0f1;
border-radius:15px;
box-shadow:5px 10px 10px rgba(136, 116, 116, 0.31);
z-index: -1
}
#Content_Products {
position:absolute;
top:100px;
width:1100px;
height: 870px ;
left:50% ;
margin-left: -550px;
background-color: #ecf0f1;
border-radius:15px;
box-shadow:5px 10px 10px rgba(136, 116, 116, 0.31);
z-index: -1
}
#TopSection {
position: absolute;
top: 0px;
width: 100%;
Height: 250px;
background-image:url(AboutUsImage.jpg);
border-bottom-style: solid;
border-bottom-color: rgba(60, 231, 178, 0.64);
border-bottom-width: 5px;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
}
#AboutUs1 {
font-family:'Ek Mukta';
color:white;
font-size: 48px;
z-index: 5;
text-align: center;
padding: 50px
}
#Info {
z-index:0;
position: absolute;
top:255px;
width: 1100px;
}
.TelescopesLink {
position:absolute;
display:inline-block;
left:585px;
top:30px;
height:250px;
width:500px;
}
.MountLink {
z-index: 1;
position:absolute;
left:15px;
top:30px;
height:250px;
width:500px;
background-color: green;
}
.MountLink:hover{
z-index: 1;
background-color: red;
}
.AstroLink {
position:absolute;
left:15px;
top:330px;
height:250px;
width:500px;
}
.AccessoriesLink {
position:absolute;
top:330px;
left:585px;
height:250px;
width:500px;
}
/*With the main culprit being */
.MountLink {
z-index: 1;
position:absolute;
left:15px;
top:30px;
height:250px;
width:500px;
background-color: green;
}
.MountLink:hover{
z-index: 1;
background-color: red;
}
<div id="Content_Products">
<div id="TopSection">
<h1 id="AboutUs1">Products</h1>
</div>
<div id="Info">
<div class="TelescopesLink">
<img src="telescopes.jpg" >
</div>
<div class="MountLink">
</div>
<div class="AstroLink">
<img src="astro.jpg" >
</div>
<div class="AccessoriesLink">
<img src="accessories.jpg"</img>
</div>
</div>
</div>
I just cant get it to work, any help or advice would be appreciated
because #Content_Products is positioned absolutely with a minus z-index, the body element is on top of it, so when you hover over the green box, you are actually hovering over the body tag above it.
if you did
body:hover .MountLink{
z-index: 1;
background-color: red;
}
you'll see it work, but the main issue is the z-index:-1 on #Content_Products
z-index is creating problem simply remover z-index form your code and everything will work good..
and css is case sensitive
in #TopSection Height shouldn be height.

Only 100% width Footer in CSS?

I have a basic HTML page where everything is wrapped inside a mainWrapper div and secondWrapper div.
everything is set to 960px size (the pageHeader, the pageContent and pageFooter).
I need to keep everything 960px apart from the pageFooter.
This is my CSS code:
<style type="text/css">
<!--
body {
}
#secondWrapper {
margin-left:auto;
margin-right:auto;
width:960px;
min-width:910px;
}
#mainWrapper{
margin-left:auto;
margin-right:auto;
width:960px;
}
#pageHeader {
height:80px;
width:100%;
min-width: 918px;
border-bottom: solid 1px #ededed;
z-index:1000;
position:relative;
}
#pageContent {
clear:both;
width:100%;
min-width: 918px;
background-image:url(img/map.png);
height:600px;
background-repeat:no-repeat;
background-position:center;
box-shadow: 6px 0px 5px -5px #999, -6px 0px 5px -5px #999;
z-index:1;
}
#pageFooter {
background-color:#CCC;
width:100%;
min-width: 918px;
}
#logo{
position: absolute;
margin-left:29px;
background-color:#cb202d;
width:120px;
height:110px;
top: 0;
text-align:center;
vertical-align:center;
display:block;
font-family:Tahoma, Geneva, sans-serif;
font-size:24px;
color:#FFF;
font-weight:bold;
float:left;
z-index:1000;
-webkit-box-shadow: 0 5px 6px -6px grey;
-moz-box-shadow: 0 5px 6px -6px grey;
box-shadow: 0 5px 6px -6px grey;
}
#logoTxt{
position: relative;
top:26%;
}
#yourCurrentTime{
float:left;
left:220px;
top:10%;
position:relative;
border: 10px solid #1abc9c;
border-radius:4px;
}
#arrow-down {
position:absolute;
width: -23px;
height: 2px;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #1abc9c;
left: 99px;
top: 30px;
}
#b {
position:absolute;
width:200px;
height:115px;
z-index:10000000;
left: -59px;
top: 48px;
background-color:#333;
display:none;
}
div#a:hover div#b {
display: inline;
}
div#a:hover {
background-color:#eceded;
cursor:pointer;
}
div#divBtn:hover {
background-color:#4a4a52;
cursor:pointer;
}
div#a{
width:140px;
height:47px;
position:absolute;
left: 825px;
top: 0px;
}
-->
</style>
I did try a few solutions found on Google and stackoverflow like this:
html,
body {
margin:0;
padding:0;
height:100%;
}
but that didn't work for me!
Any help would be appreciated.
Here is the Jsfiddle: http://jsfiddle.net/crf121359/jwgfH/
You need to do it like this:
HTML
<div class="wrap">
<div class="wrap_inner>
<!-- Pwraput here your pageHeader and pageContent -->
</div>
</div>
<footer>
</footer>
CSS
.wrap {
position: relative;
min-height: 100%;
padding-bottom: 200px /*footer height*/
}
.wrap_inner {
width: 960px;
margin: 0 auto;
}
footer {
width: 100%;
height: 200px;
position: absolute;
left: 0;
bottom: 0;
}
You just need to take your pageFooter outside of the wrapper.
Here's a working example:
http://jsfiddle.net/jwgfH/3/
You should see how it looks here, not inside the little frame:
http://jsfiddle.net/jwgfH/3/show
width: 100%;
only works if the parent element has a width defined.
Try giving your body element a max-width and see if that works
can you show your html too ? if the parent div or container is having 100% width then it should show the perfect result.
If you want to create a webpage that's 960px wide, define it in your <body> tag's by placing width:960px; in the CSS.
Then, use width:100%; in the rest of your elements - only for those that you want to display as 960px. The rest can be divided by using width:50%;, width:25%;, which is 50% of 960px and 25% of 960px respectively.
Also, height:100% is negligible, the rest of the elements will automatically define the height of the webpage, as long as you place them correctly.
In short, do this:
body {
width:960px;
margin:0 auto;
}
#secondWrapper {
width:100%;
float:left;
}
...and so on and so forth.
(NOTE: To solve your positioning problem, float:left is probably the best way to go. Use it on most of the elements you need to position accurately. If not, the browser will estimate where it will go.)
AFTER EDIT:
If you want a 960px gap between the #pageContent and #pageFooter, you can always define a margin-top like this:
#pageFooter {
margin-top:960px;
}