first, let me give advance thanks for any assistance up top here since this is a long post. i’ve just spent the past five hours trying to figure this out on my own.
how do i place a page background image that scales to the width of the window with a height proportional to the original image size. the rest of the page backgrounds will be a color.
also for the same project but not as critical, is there a standards-based way to set an element background color opacity but still have the text at 100% opaque?
i want a “forward facing” page that validates as transitional but uses as much HTML5/CSS3 as possible within that parameter. or is it ok to validate HTML5/CSS3 as coding to web standards now so long as you know what won’t work in <IE9 so your design stays nice? what is the best practice for claiming to be a standards-based designer/coder in this latest time of transition?
my main resources were:
http://www.pziecina.com/portfolio/page_one.php, and
http://css-tricks.com/perfect-full-page-background-image/ (css 1 and 2 versions)
here is my modified code fore each, or, you can download the attached zip. (the image link is absolute to an online image.)
css-1:
<!--<!DOCTYPE HTML>-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Full Page Background Image | CSS #1</title>
<style>
body{
margin:0;
padding:0;
background-color: #4e4d30;
}
img.bg {
/* Set rules to fill background */
/*min-height: 100%;*/
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
}
@media screen and (max-width: 1024px){
img.bg {
left: 50%;
margin-left: -512px; }
}
.transparent_class {
filter:alpha(opacity=70);
/*-moz-opacity:0.7;
-khtml-opacity: 0.7;*/
opacity: 0.7;
}
#page-wrap { position: relative; width: 800px; margin: 0px auto 50px auto; padding: 20px; background: #FFFFdd; border: 1px solid #4e4d30; -moz-box-shadow: 0 0 20px black; -webkit-box-shadow: 0 0 20px black; box-shadow: 0 0 20px black; opacity: 70%;}
p { font: 15px/2 Georgia, Serif; margin: 0 0 30px 0; text-indent: 40px;}
</style>
</head><body>
<img src="http://mtouchette.com/testing/onLandBkg.png" class="bg">
<div id="page-wrap" class="transparent_class">
<p>Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat
vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet
quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat
eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra.
Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet,
wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum
rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis
pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus
faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor,
facilisis luctus, metus</p>
</div>
</body></html>
css-2:
<!--<!DOCTYPE HTML>-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Full Page Background Image | CSS #2</title>
<style>
body{
margin:0;
padding:0;
}
#bg {
position:fixed;
top:-50%;
left:-50%;
width:200%;
height:200%;
background-color:#4e4d30;
}
#bg img {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
margin:auto;
min-width:50%;
min-height:/*50%*/auto;
}
#wrapper { position: relative; z-index: 2; width: 800px; margin: 0px auto 50px auto; padding: 20px; Border: 1px solid #4e4d30;background: white; -moz-box-shadow: 0 0 20px black; -webkit-box-shadow: 0 0 20px black; box-shadow: 0 0 20px black; }
p { font: 15px/2 Georgia, Serif; margin: 0 0 30px 0; text-indent: 40px; }
</style>
<!--<script src="css-2.php_files/bsa.js" async="" type="text/javascript"></script><script src="css-2.php_files/ga.js" async="" type="text/javascript"></script>--></head><body>
<div id="wrapper">
<p><strong>Original source code: http://css-tricks.com/examples/FullPageBackgroundImage/css-2.php#</strong></p>
<p>Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat
vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet
quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat
eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra.
Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet,
wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum
rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis
pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus
faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat.
Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor,
facilisis luctus, metus</p>
</div>
<!-- At bottom, 'cause it's not really content -->
<div id="bg">
<img src="http://mtouchette.com/testing/onLandBkg.png" alt="">
</div>
</body></html>
page_one:
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>P. Ziecina - Portfolio cover page.</title>
<meta http-equiv="X-FRAME-Options" content="Deny">
<style type="text/css">
<!--
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
}
/* The body is the outermost layout component and contains the visible page content. Setting properties for the body element will help to create consistent styling of the page content and more manageable CSS. Besides using the body element to set global properties, it is common to use the body element to set the background color of the page and create a centered container for the page content to display. */
body {
color: #2a2d2e;
background-color: #3366FF;
font-family: Georgia, Palatino, "Palatino Linotype", Times, "Times New Roman", serif;
font-size: 12px;
margin: 0 0 0 0; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
padding: 0 0 0 0; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
text-align: center; /* Centers the page content container in IE 5 browsers. */
background: #3366FF url(http://mtouchette.com/testing/onLandBkg.png) center center fixed no-repeat;
-moz-background-size: cover;
background-size: cover;
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../portfolio/images/Dock.jpg', sizingMethod='scale')";
}
@media only all and (max-width: 1024px) and (max-height: 768px) {
body {
-moz-background-size: 1024px 768px;
background-size: 1024px 768px;
}
}
#outerWrapper {
margin: 0 auto 0 auto; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
text-align: left; /* Redefines the text alignment defined by the body element. */
width: 1000px;
background-color: transparent;
position: relative;
}
#outerWrapper #header {
font-size: 18px;
font-weight: bold;
line-height: 15px;
padding: 0px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
background-color:#FFFFFF;
}
h1 {
font-family:"ChopinScript","Lucida Grande","Lucida Sans Unicode",arial,sans-serif;
color: #D31988;font-size: 3em;
font-style: italic;
font-weight: lighter;
margin-top: 30px;
}
.largeh6 {
font-size: 5em;
font-family: Impact, Haettenschweiler, "Franklin Gothic Heavy", "Helvetica Inserat", "Arial Black", sans-serif;
color: #090;
line-height: 1em;
}
.largeh5 {
color: #000;
margin: 0.5em 0 0 0.25em;
}
-->
</style>
<!--<link href="page_one.php_files/portfolio.css" rel="stylesheet" type="text/css" media="screen">-->
</head>
<body>
<div id="outerWrapper">
<div id="header">
<h6 class="largeh6">Hello</h6>
<h5 class="largeh5">welcome to the portfolio section of:</h5>
<h1>P. Ziecina (.com)</h1>
<p> </p>
</div>
</div>
</body></html>