Responsive Design with a background image

时间:2017-01-10 02:31:01

标签: html css responsive-design

I am working in Dreamweaver CS6 to create a small website. I have been fighting with the menu, trying responsive image maps and image links with no success.

What I'm trying now is a fluid background image, but it isn't adjusting in size correctly.

Any help would be greatly appreciated. I want to add text links on top of the blue background and to the right of the logo.

Here is the html:

 <!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled Document</title>
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="BodyShop.css" rel="stylesheet" type="text/css">
<style type="text/css">

body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: medium;
    color: #1A365E;
}
body {
    background-color: #8F8473;
    background-image: url(Images/Site_bkg.png);
    background-repeat: repeat-x;
    margin-left: 0%;
    margin-top: 0%;
    margin-right: 0%;
    margin-bottom: 0%;
}
a {
    font-size: medium;
    color: #1A365E;
}
a:link {
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #808D9F;
}
a:hover {
    text-decoration: underline;
    color: #1A365E;
}
a:active {
    text-decoration: none;
    color: #1A365E;
}
</style>


<!-- 
To learn more about the conditional comments around the html tags at the top of the file:
paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/

Do the following if you're using your customized build of modernizr (http://www.modernizr.com/):
* insert the link to your js here
* remove the link below to the html5shiv
* add the "no-js" class to the html tags at the top
* you can also remove the link to respond.min.js if you included the MQ Polyfill in your modernizr build 
-->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>  

<div class="gridContainer clearfix">
  <div id="LayoutDiv1"><img src="Images/Site_NavLine.png" alt="NavLine"></div>
  <div id="LayoutDiv2">
    <div align="center"><em><img src="Images/Site_HomeTop.png" alt="PageTop"></em></div>
  </div>
  <div id="LayoutDiv3">
    <div align="center"><img src="Images/Site_home.png"></div>
  </div>
  <div id="LayoutDiv4">
    <div align="center">3961 Abbott Dr.  |  S Hwy 71  |  Willmar, MN 56201<br>
Phone: 320-235-0095  |  Fax: 320-235-3239  |  Email: bondo-71@hotmail.com<br>
HOURS: Monday-Thursday 8:00-5:00, Friday 8:00-4:00<br>
© 2017 The Body Shop 71, Willmar, MN</div>
  </div>
</div>
</body>
</html>

Here is the CSS:

@charset "UTF-8";
/* Simple fluid media
   Note: Fluid media requires that you remove the media's height and width attributes from the HTML
   http://www.alistapart.com/articles/fluid-images/ 
*/
img, object, embed, video {
    max-width: 100%;
}
/* IE 6 does not support max-width so default to width 100% */
.ie6 img {
    width:100%;
}

.responsive-scale:{
        width:100%;
        padding-bottom: 66.666666666667%; /*960px/1440px */
        background-image:Images/Site_bkg.png;
        background-size:cover;
        background-position:center; /* IE fix*/
}


/*
    Dreamweaver Fluid Grid Properties
    ----------------------------------
    dw-num-cols-mobile:     5;
    dw-num-cols-tablet:     5;
    dw-num-cols-desktop:    5;
    dw-gutter-percentage:   10;

    Inspiration from "Responsive Web Design" by Ethan Marcotte 
    http://www.alistapart.com/articles/responsive-web-design

    and Golden Grid System by Joni Korpi
    http://goldengridsystem.com/
*/

/* Mobile Layout: 480px and below. */

.gridContainer {
    margin-left: auto;
    margin-right: auto;
    width: 89.3454%;
    padding-left: 0.8272%;
    padding-right: 0.8272%;
}
#LayoutDiv1 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv2 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv3 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv4 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}

/* Tablet Layout: 481px to 768px. Inherits styles from: Mobile Layout. */

@media only screen and (min-width: 481px) {
.gridContainer {
    width: 91.309%;
    padding-left: 0.8454%;
    padding-right: 0.8454%;
}
#LayoutDiv1 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv2 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv3 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv4 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
}

/* Desktop Layout: 769px to a max of 1232px.  Inherits styles from: Mobile Layout and Tablet Layout. */

@media only screen and (min-width: 769px) {
.gridContainer {
    width: 88.3636%;
    max-width: 1232px;
    padding-left: 0.8181%;
    padding-right: 0.8181%;
    margin: auto;
}
#LayoutDiv1 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv2 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv3 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
#LayoutDiv4 {
    clear: both;
    float: left;
    margin-left: 0;
    width: 100%;
    display: block;
}
}

0 个答案:

没有答案