位置图像外主要内容

时间:2011-12-13 08:44:08

标签: xhtml css-float css

我有以下代码,但我的问题是关于横幅图片

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title Goes Here</title>
<style type="text/css">
<!--
body {
    font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    color: #000;
    background-attachment: scroll;
    background-image: url(11.12.12_RBM2012_bkg01.jpg);
    background-repeat: no-repeat;
    background-position: center top;
}

/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
    padding: 0;
    margin: 0;
}
h1, h2, h3, h4, h5, h6, p {
    margin-top: 0;   /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
    padding-right: 15px;
    padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
}
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
    border: none;
}

/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
    color: #42413C;
    text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
}
a:visited {
    color: #6E6C64;
    text-decoration: underline;
}
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
    text-decoration: none;
}

/* ~~ This fixed width container surrounds all other divs ~~ */
.container {
    width: 920px;
    margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
    background-color: #000;
}
.header {
}


.content {

    padding: 10px 0;
    width: 920px;
    float: left;
}

/* ~~ This grouped selector gives the lists in the .content area space ~~ */
.content ul, .content ol { 
    padding: 0 15px 15px 40px; 

/* ~~ The footer styles ~~ */
.footer {
    padding: 10px 0;
    position: relative;/* this gives IE6 hasLayout to properly clear */
    clear: both; /* this clear property forces the .container to understand where the columns end and contain them */
}

/* ~~ Miscellaneous float/clear classes ~~ */
.fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
    float: right;
    margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
    float: left;
    margin-right: 8px;
}
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the .container) if the .footer is removed or taken out of the .container */
    clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}

.banner {
}
-->
</style></head>

<body>

<div class="container">

<img src="banner.jpg" width="120" height="600" alt="Banner" class="banner">

  <div class="header"><a href="#"><img src="11.12.12_RBM2012_header01.jpg" alt="Insert Logo Here" name="Insert_logo" width="920" height="240" id="Insert_logo" style="background: #C6D580; display:block;" /></a> 
  <!-- end .header --></div>

  <div class="content">
    <p>Content</p>
  <!-- end .content --></div>

    <p>Content</p>
<!-- end .footer --></div>
  <!-- end .container --></div>
</body>
</html>

我希望将它放在主容器外面,右侧,标头下方。希望下面是我需要的一个例子。有什么帮助吗?

enter image description here

1 个答案:

答案 0 :(得分:2)

将container-element设置为相对位置:

.container {
    width: 920px;
    margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
    background-color: #000;
    position: relative;
}

现在您可以为横幅提供相对于容器的绝对位置:

.banner {
position: absolute;
left: 100%;
top: 50px;
}

你可以改变当然的最高位置。如果横幅和容器之间需要一些空间,请在横幅上尝试一些css-margin。