browser no longer displaying gradient background - css

I'm trying to put a banner image (with transparent section) in a div, over a gradient background that I can change dynamically, and then overlay a table on top of it all.
<div style="margin: 0; padding: 0; width: 796px; position: relative; ">
<img src="LeftSlice.gif" style="margin: 0; padding: 0; position: relative; float: left;">
<div style="margin: 0; padding: 0;
background: -webkit-linear-gradient(white, blue);
background: -o-linear-gradient(white, blue);
background: -moz-linear-gradient(white, blue);
background: linear-gradient(white, blue);
">
<img src="MiddleSlice2.gif" style="margin: 0; padding: 0; position: relative; float: left; z-index: 250; ">
</div>
<img src="RightSlice.gif" style="margin: 0; padding: 0; position: relative; float: left; ">
<table style="padding: 0 20px; width: 796px; position: absolute; left:10px; top:10px; z-index: 500 " >
<tr>
<td valign="bottom" align="left"><img src="IFFUlogo.gif" height="80px" width="200px" ></td>
<td valign="top" align="right">About Us | Register | Login</td>
</tr>
<tr>
<td colspan="2" valign="bottom" align="center" style="padding: 30px 0 0 0; color: white; "><h1>Custer County District High School</h1></td>
</tr>
</table>
</div>
I'm getting no gradient (body bg is showing under transparent portion of the banner .gif)
When I look at the element in Firebug, I get this:
element.style {
background: linear-gradient(#FFFFFF, #0000FF) repeat scroll 0 0 rgba(0, 0, 0, 0);
margin: 0;
padding: 0;
}
I don't think we are allowed to post URLs, but if so, I can do so.

Looks like everything inside your divs is either floating or position:absolute. This will cause the divs to collapse in on themselves, so that you can't see the background. Anytime you float something inside of a container that you want to expand to contain its contents, you either need to insert a clear like this:
<div id="myContainer" style="background:red;">
<img id="myFloatingElem" style="float:left;" />
<div style="clear:left;"></div>
</div>
Or better yet, don't do that, and use a Clearfix instead (See http://nicolasgallagher.com/micro-clearfix-hack/ for accompanying css):
<div id="myContainer" class="cf" style="background:red;">
<img id="myFloatingElem" style="float:left;" />
</div>
For position:absolute, neither option will work, you need to specify a height for the parent in this case.

I tested your CSS gradient code and it works. I see the problem is in the float: left of the image inside the div tag with the gradient background but I don't know what output you wish to see because the image files are not available. Maybe you can post it clearly.

Related

Adding simple css to iframe/html

I have got some HTML code from investing.com below:
<iframe frameborder="0" height="380" width="230" src="https://ssltools.forexprostools.com/currency-converter/index.php?from=17&to=12&force_lang=1"></iframe><br /><table width="197"><tr><td><span style="font-size: 11px;color: #333333;text-decoration: none;">The Currency Converter is powered by Investing.com</span></td></tr></table>
The output is look like the picture below:
enter image description here
And I would like to add css to make the background like below:
Rounded rectangle, 30 opacity with light green, maybe 10 px for margins
enter image description here
Can anybody help me. I am new for html and css. Thank you very much.
Lawrence
just add wrapping div and css class .frame {} with colored border
.frame {
display: inline-block;
border: 30px solid ;
border-color: rgba(200,255,200,0.6);
border-radius: 30px;
margin: 10px;
}
<div class="frame"><iframe frameborder="0" height="380" width="230" src="https://ssltools.forexprostools.com/currency-converter/index.php?from=17&to=12&force_lang=1"></iframe><br /><table width="197"><tr><td><span style="font-size: 11px;color: #333333;text-decoration: none;">The Currency Converter is powered by Investing.com</span></td></tr></table></div>
<style>
.frame {
display: inline-block;
border: 30px solid ;
border-color: rgba(200,255,200,0.6);
border-radius: 30px;
margin: 10px;
}
</style>
<div class="frame"><iframe frameborder="0" height="380" width="230" src="https://ssltools.forexprostools.com/currency-converter/index.php?from=17&to=12&force_lang=1"></iframe><br /><table width="197"><tr><td><span style="font-size: 11px;color: #333333;text-decoration: none;">The Currency Converter is powered by Investing.com</span></td></tr></table></div>
I suggest you to put the iframe to a div. In this example .iframe-container. So the HTML will look like this:
<div class="iframe-container">
<iframe frameborder="0" height="340" width="210" src="https://ssltools.forexprostools.com/currency-converter/index.php?from=17&to=12&force_lang=1"></iframe>
</div>
<br />
<table width="197">
<tr>
<td>
<span style="font-size: 11px;color: #333333;text-decoration: none;">The Currency Converter is powered by Investing.com
</span>
</td>
</tr>
</table>
Please note that I changed the with and height of the iframe since the form it was containing, was not matched with the initial attributes. You can reset it if you'd like.
Then write some CSS as below:
.iframe-container {
display: inline-block;
margin: 30px;
padding: 30px;
background: rgba(0, 255, 0, .3);
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
}
iframe {
margin: 0;
padding: 0;
background: white;
}
See the result at jsFiddle.
Sorry! I know that is my problem that I tried many times to combine those HTML and css together, but doesn't work.
My purpose is only want to have "a batch of code" to paste into the website.
Thank you for your concern.

White div background displays as grey

I have a content div displaying an image and a header positioned on/at the top of the content div. The original background for the header (which contains some text) is black with some opacity, when the user hovers over the image/header the background color and text color of the header div change to white/black. However I've found that setting the background to white results in an off gray color instead (regardless of opacity). What should I use to get opacity to work with a white background? Attached is the CSS for what I'm doing. #textWrap (header w/ text) is inside of #gameDisplayBugSmash (an image).
#gameDisplayBugSmash {
height: auto;
width: 50%;
position: relative;
}
#gameDisplayBugSmash:hover #textWrap {
background-color: white;
color: #000;
}
#textWrap {
background-color: rgba(0,0,0, .6);
width: 100%;
height: auto;
z-index: 1;
left: 0px;
top: 0px;
position: absolute;
font-size: 16px;
color: #FFF;
}
<div id = "contentSaver">
<div id = "contentGames">
<div id = "gameDisplayBugSmash">
<img src="images/PortII_DesignMocks-Recovered_0002s_0005_Layer-17-copy-3.png" width="100%" height="auto" id="bugSmash" />
<div id = "textWrap">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div id = "bugSmashTitle">Bug Smash</div>
</td>
<td>
<div id = "bugSmashTextD">A final project for one of my coding classes. This was my introduction to using monogame for development.</div>
</tr>
</table>
</div>
</div>
</div>

Chrome CSS border issue

I've found some very strange behaviour with Chrome with respect to the following CSS...
CSS:
table.addressBody {
width: 100%;
min-width: 100%;
}
table.addressBody tr td {
padding: 4px;
width: 40%;
min-width: 40%;
max-width: 40%;
border: none;
vertical-align: middle;
}
table.addressBody tr td.left, table.addressBody tr td.right {
background-color: White;
border: 2px solid #aaa;
}
table.addressBody tr td.centre {
width: 20%;
min-width: 20%;
max-width: 20%;
text-align: center;
}
HTML:
<div class="fitWidth centre">
<strong>Mr Smith</strong><br />
29/05/2014 11:17:00 - Department, Site
</div>
<table class="addressBody">
<tr>
<td class="left">
<select name="ctl00$phBody$repPatients$ctl01$ddlPickup" id="ctl00_phBody_repPatients_ctl01_ddlPickup"></select>
</td>
<td class="centre" style="border: none;"> </td>
<td class="right">
<select name="ctl00$phBody$repPatients$ctl01$ddlDest" id="ctl00_phBody_repPatients_ctl01_ddlDest"></select>
</td>
</tr>
<tr>
<td class="leftShadow" colspan="2">
<img src="../img/other/bottomShadowLt.png" alt="Shadow" />
</td>
<td class="rightShadow">
<img src="../img/other/bottomShadowRt.png" alt="Shadow" />
</td>
</tr>
</table>
(Fiddle)
The problem is the centre cell of the table which has a bottom border, despite the fact that I haven't actually specified that there should be one. I've tried the same code in both IE and FF and both produce the desired result (two outer cells with borders and the inner without).
I have also tried coding the CSS in turn for each border on all of the cells, but as soon as I code the #left cell bottom-border the centre cell is also bordered on the bottom. Also, notice in relation to this question there is no border collapse in the code (unless it's part of Fiddle itself).
Can anyone spot anything obvious that I've missed or know of any bug with Chrome that has a workaround?
-- EDIT --
But you did specify that it have a bottom border:
table.addressBody tr td.centre {
width: 20%;
min-width: 20%;
max-width: 20%;
border-bottom: 2px solid #aaa; <---
text-align: center;
}
As it turns out, my post is, in fact, a duplicate of this question, and so, if you wish to close it, please feel free.

Place div over other elements

I'm trying to place an icon over a div but the overlaying div is pushing the rest of the contents down. I'm stuck although it should be pretty easy. Please have a look at this fiddle and let me know what I'm doing wrong (apart from using tables in the design!)
body{
background-color: #666;
}
.sizesbg {
background-color:#fff;
-webkit-border-radius: 10px;
border-radius: 10px;
width: 170px;
text-align: center;
}
.soldicon {
background: url("http://www.oroeora.gr/preowned/images/sold_curl_small.png") no-repeat scroll left top transparent;
height: 155px;
left: 0;
top: 0;
width: 170px;
z-index: 2;
}
<table>
<tr>
<td class="sizesbg">
<div style="width:150px; overflow:hidden; max-height:140px; max-width:150px; min-height:100px;">
<img src="http://www.carfolio.com/images/dbimages/zgas/manufacturers/id/843/bmw-logo.png" width="140" height="140">
</div>
</td>
<td class="sizesbg">
<div class="soldicon"></div>
<div style="width:150px; overflow:hidden; max-height:140px; max-width:150px; min-height:100px;">
<img src="http://mcurrent.name/atarihistory/warner_books_logo.gif" width="140" height="140">
</div>
</td>
<td class="sizesbg">
<div style="width:150px; overflow:hidden; max-height:140px; max-width:150px; min-height:100px;">
<img src="http://www.mindxstudio.com/images/mindxstudio-logo-icon.jpg" width="140" height="140">
</div>
</td>
</tr>
</table>
Thanks!
use position:absolute; on the divs, but of course the parent elements need to have position:relative; to stay in the right place
something like this:
http://jsfiddle.net/EESAc/5/
Edit:
This works well in Chrome ... but some other browsers had troubles (eg. Firefox), because for table elements position property is not defined, and you should use a block element instead ... so it works if you use another div around the images and set its position to relative. I added another quick fiddle for an idea:
http://jsfiddle.net/EESAc/9/
Give the class .soldicon a position: absolute; This way the element will be taken out of the document flow and won't affect the other elements.
Try to add the following to your .soldicon css:
position:absolute;
DEMO
Change your css to this:-
.soldicon {
background: url("http://www.oroeora.gr/preowned/images/sold_curl_small.png") no-repeat scroll left top transparent;
display: block;
height: 155px;
left: -7;
top: 0;
width: 170px;
z-index: 2;
position:absolute; // Change to absolute positioning
}
In my case (included popup element is bigger then including element) position: absolute;
didn't work exactly how I needed it (scrolling bar was added onto including element and the included popup wasn't displayed entirely). So the solution was:
position: fixed;

Center label vertically in table

I'm trying to create a layout with 4 small images and a label centered vertically, the label could have multiple lines. The label sits on top of and obscures the images. The label will be dynamically toggled.
I have done this with divs or tables but run into the same problem. Here is my table version as close as I can get:
p.label
{
position: absolute;
background: black;
color:white;
font-weight: bold;
text-align:center;
bottom:50%;
margin:0;
word-wrap: break-word;
}
table.groupbox
{
position:relative;
}
<table class="groupbox" cellspacing=0 cellpadding=0>
<tr>
<td><p class="label">two line<br>label</p>
<img src="A.jpg" height=80 width=80></td>
<td><img src="B.jpg" height=80 width=80></td>
</tr>
<tr>
<td><img src="C.jpg" height=80 width=80></td>
<td><img src="D.jpg" height=80 width=80></td>
</tr>
</table>
This correctly has the label spanning the full table, but it puts the bottom edge of the label at the vertical center. If I change the label's margin to something like this:
margin: 0 0 -20px 0;
I can hand center the label, but it won't work for different size labels.
Two Answers
The answers by Nathan Manousos and Rob W both seem to work well.
This piece of code will produce a square with a 160x160 size. You can adjust the width and height to your wishes.
CSS:
.groupbox, .groupbox .label-container {
width: 160px;
height: 160px;
}
.groupbox {
position: relative;
}
.groupbox .label-container {
display: table;
position: absolute;
}
.groupbox .A, .groupbox .B, .groupbox .C, .groupbox .D{
width: 50%;
height: 50%;
background-position: center;
position: absolute;
background-repeat: no-repeat;
}
.groupbox .A{background-image:url("A.jpg");top:0;left:0;}
.groupbox .B{background-image:url("B.jpg");top:0;right:0;}
.groupbox .C{background-image:url("C.jpg");bottom:0;left:0;}
.groupbox .D{background-image:url("D.jpg");bottom:0;right:0;}
.groupbox .label {
display: table-cell;
text-align: center;
vertical-align: middle;
}
HTML:
<div class="groupbox">
<div class="A"></div><div class="B"></div>
<div class="C"></div><div class="D"></div>
<div class="label-container">
<div class="label">Any text<br />With multiple lines</div>
</div>
</div>
Final edit
Keep in mind that background should be a background. The text should not become unreadable because of the background. To accomplish this, you can create a 1x1 transparent image:
.groupbox .label-container {
background:url("transparent.png") repeat transparent;
}
You can also use background-color:rgba(1,1,1,0.2) where 0.2 is the transparency level (0=invisible, 1=fully visible). This CSS attrbute is available for FF 3+, Chrome, Safari 3+, Opera 10+ and IE 9+.
Okay, based on the updated diagram, here is a solution that requires knowing the height of the whole box.
Here it is in action: http://jsfiddle.net/raySU/
CSS:
*{margin:0;padding:0;}
#wrap{width:200px; height:200px; position:relative;}
#wrap #images{position:absolute;}
#wrap #images img{float:left;}
#wrap #label{position:absolute; width:200px; height:200px;}
#wrap #label table{width:100%; height:100%;}
#wrap #label p{background-color:#eee;}
HTML:
<div id="wrap">
<div id="images">
<img src="http://placekitten.com/100" width="100" height="100" />
<img src="http://placekitten.com/100" width="100" height="100" />
<img src="http://placekitten.com/100" width="100" height="100" />
<img src="http://placekitten.com/100" width="100" height="100" />
</div>
<div id="label">
<table cellspacing="0" cellpadding="0">
<tr>
<td valign="center">
<p>This is my label here isnt it great yes it is</p>
</td>
</tr>
</table>
</div>
</div>
If you add a container around your table, you should be able to do this pretty easily.
<div class="container">
<table class="groupbox" cellspacing=0 cellpadding=0>
<tr>
<td>
<p class="label">two line<br>label</p>
<img src="A.jpg" height=80 width=80>
</td>
<td><img src="B.jpg" height=80 width=80></td>
</tr>
<tr>
<td><img src="C.jpg" height=80 width=80></td>
<td><img src="D.jpg" height=80 width=80></td>
</tr>
</table>
<p class="label">Your text here</p>
</div>
.container {
position: relative;
float: left; }
.label {
position: absolute;
top: 50%;
right: 0;
height: 18px; /* fixed height */
margin: -9px 0 0; }

Resources