将图像放置在主要内容之外

发布于 2024-12-21 01:35:49 字数 4471 浏览 1 评论 0原文

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

<!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>

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

在此处输入图像描述

I have the following code but my question is about the banner image

<!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>

I wish to place this outside the main container, to the right, below the header. Hopefully below, is an example of what I need. Any help?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦罢 2024-12-28 01:35:49

为容器元素指定一个相对位置:

.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。

Give the container-element a position relative:

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

now you can give the banner an absolute position relative to the container:

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

you can change the top-position of course. if you need some space between the banner and the container, try some css-margin on the banner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文