I am trying to do is make a clear div box to work cross-browser (Mozilla, Chrome, Opera, IE 9+, Safari) + IE 6, 7, and 8 like that pictured below:
http://s29.postimg.org/8hp8m56gm/5_21_2014_12_06_38_AM.jpg
I got it to work in all the other browsers except IE 6, 7, and 8.
To approach this, I utilized @potench's response found here: How does one target IE7 and IE8 with valid CSS?. This was extremely helpful, however I cannot get it to work with IE 6, 7, 8 because @potench's advice only describes how to use it with selectors (which makes sense it most cases). However, my case is different. My logic tells me that since I am trying to create a clear div box for IE 6, 7, and 8, I need to do it with a class. In short, use a class to select (sp?) another class. What I tried to do was use the class ie8
to select transboxBody
, but this did not work:
.ie8 transboxBody{
background-color: #fff;
filter:alpha(opacity=60);
}
Instead of this, I tried to select second div element in my HTML:
div:second-child {
background-color: #fff;
filter:alpha(opacity=60);
}
This should select this div element:
<div class="transboxHead">
<img src="../_images/image">
<h2>Header text</h2>
</div>
However, this did not work as it effected the div box color in Mozilla, Chrome, Opera, IE 9+, and Safari.
So in sum: is there an easier way to do this? Can I select a class with another class? If not, what would be the best way to approach this?
Please note that I am not interested in using Jquery for learning purposes... I want to get this to work with as clean of code possible, and having a Jquery function will add more bulk.
Here's my code...
CSS:
/*Zeroes out all margins*/
* {
margin:0;
padding:0;
}
/*Center align website*/
#wrapper {
width:47em;
margin:0 auto;
text-align:left;
}
body {
text-align:center; /*For IE6*/
}
/*Background image for website*/
html, body {
background-image:url("../_images/Background.jpg");
}
/*Top transparent box*/
.transboxHead {
background-color:rgba(255,255,255, 0.6);
opacity: 0.6;
border-radius: 0 0 25px 25px;
padding: 1em;
}
/*Body transparent box*/
.transboxBody {
margin:30px 0px;
background-color:rgba(255,255,255, 0.3);
border-radius:25px;
padding: 1em;
}
.ie6 transboxBody{
background-color: #fff;
filter:alpha(opacity=60);
}
/*Registartion form styling*/
.logregform li {
margin: 10px;
/*I added the width and height seen below to try to get it work in Chrome*/
padding:top;
width:220px;
height:30px;
}
/*Center fields*/
.contact_form {
width:240px;
overflow:hidden;
padding:10px;
}
/*Contact form styling*/
.contact_form ul {
list-style-type:none;
list-style-position:outside;
margin:0px;
padding:0px;
}
HTML:
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<link type="text/css" rel="stylesheet" href="../_css/stylesheet.css"/>
</head>
<div id="wrapper">
<div class="transboxHead">
<img src="../_images/image">
<h2>Header text</h2>
</div>
<div class="centered transboxBody">
<div class="logregform">
<form class="contact_form">
<ul>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</form>
</div>
</div>