html - 背景图像标题的 CSS 和 HTML 编码建议

标签 html css

我是 CSS 的新手,我想在我的新网站上放一个标题。

一个简单的,只有一张图片放在最上面的背景上。我真的不知道如何在没有大量编码的情况下做到这一点。

所以,这是 what i have , 这是 what i want .而在这个问题的最后是实际页面的代码。有任何想法吗?非常感谢!

<!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" dir="ltr" lang="es-ES"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Tablon</title> 
    <link rel="stylesheet" href="LIB/main.css" type="text/css" media="screen" /> 
    <link rel="stylesheet" type="text/css" href="LIB/titulos.css"> 
    <!--[if IE]>
        <link rel="stylesheet" href="LIB/ie.css" type="text/css" media="screen" />
    <![endif]--> 
    <style type="text/css"> 
.style1 {
    text-align: right;
}
    .style2 {
        vertical-align: top;
        margin-top: 3pt;
        margin-bottom: 3pt;
    }
    #apDiv1 {
    position:absolute;
    left:116px;
    top:398px;
    width:800px;
    height:37px;
    z-index:1;
    text-align: center;
    font-family: Verdana, Geneva, sans-serif;
    font-size: 9px;
}
    </style> 
</head> 
<body> 
<script type="text/javascript" src="JS/jquery-1.3.2.js"></script> 
<marquee> 
</marquee> 

    <div class="wrapper"> 
      <p>&nbsp;</p> 
      <p><br /> 
      </p> 
      <center>&nbsp;</center> 
        <div class="aux"> 
          <div id="container"> 
<ul class="menu"> 
                    <li id="noticias" class="active">Mensajes</li> 
                    <li id="tutoriales">Profesores</li> 
                    <li id="enlaces">Enlaces</li> 
            </ul> 
                <span class="clear"></span> 
                <div class="content noticias"> 

                    <h3>Ultimos mensajes</h3> 
                    <br /> 
                  <div class="style1" style="vertical-align: middle; text-align: right; background-color: #1E1E1E; height: 21px;"> 
                    <img alt="" height="16" src="IMG/feed16.png" width="16" class="style2" /> 
                        <a href="rssfeed.php">Subscribirce al canal RSS </a> 
                  </div> 
                  <ul> 
                    <br> 
                      <div id="todo"> 
                        <div id="foto" style="float: left;width: 86px;height: 80px;padding: 3px"> 
                        <IMG src="http://www.gravatar.com/avatar/78bb533a50590a8414a496e2ee57420a?size=80" alt="-" /> 
                        </div> 
                        <div id="sms" style="height: 86px;background-color: #1E1E1E;"> 
                        <a href="msgs.php?user=djsoftlayer"> djsoftlayer</a>: Este texto sera utilizado para probar el formato de las comillas quote1 y quote2 cuando lo que se escribe es suficiente texto como para copar los 300 caracteres, o al menos una gran parte de los 300, ya no me queda mas nada que decir, asi que voy a tratar de llegar a 300 hablando paja, paja, ya lleg
                        </div> 
                        </div> 
<div id="comenta" style="width:30%;float: right;"> <a href="comments.php?ref=44&autor=djsoftlayer&foto=http://www.gravatar.com/avatar/78bb533a50590a8414a496e2ee57420a?size=80&sms=Este texto sera utilizado para probar el formato de las comillas quote1 y quote2 cuando lo que se escribe es suficiente texto como para copar los 300 caracteres, o al menos una gran parte de los 300, ya no me queda mas nada que decir, asi que voy a tratar de llegar a 300 hablando paja, paja, ya lleg"> 
    <img alt="" height="16" src="IMG/comen16esp.png" width="64" style="float: right" /></a></div> 
                        <br><div id="todo"> 
                        <div id="foto" style="float: left;width: 86px;height: 80px;padding: 3px"> 
                        <IMG src="http://www.gravatar.com/avatar/78bb533a50590a8414a496e2ee57420a?size=80" alt="-" /> 
                        </div> 
                        <div id="sms" style="height: 86px;background-color: #1E1E1E;"> 
                        <a href="msgs.php?user=djsoftlayer"> djsoftlayer</a>: testing
                        </div> 
                        </div> 
<div id="comenta" style="width:30%;float: right;"> <a href="comments.php?ref=43&autor=djsoftlayer&foto=http://www.gravatar.com/avatar/78bb533a50590a8414a496e2ee57420a?size=80&sms=testing"> 
    <img alt="" height="16" src="IMG/comen16esp.png" width="64" style="float: right" /></a></div> 
                        <br><div id="todo"> 
                        <div id="foto" style="float: left;width: 86px;height: 80px;padding: 3px"> 
                        <IMG src="http://www.gravatar.com/avatar/e830bd0ff9aae265d91fe554eb65a61f?size=80" alt="-" /> 
                        </div> 
                        <div id="sms" style="height: 86px;background-color: #1E1E1E;"> 
                        <a href="msgs.php?user=nata"> nata</a>: grande
                        </div> 
                        </div> 
<div id="comenta" style="width:30%;float: right;"> <a href="comments.php?ref=42&autor=nata&foto=http://www.gravatar.com/avatar/e830bd0ff9aae265d91fe554eb65a61f?size=80&sms=grande"> 
    <img alt="" height="16" src="IMG/comen16esp.png" width="64" style="float: right" /></a></div> 
                        <br>                  </ul> 
            </div> 
                <div class="content tutoriales"> 
                    <h3>Profesores</h3> 
                    <ul> 
                    <br><li><IMG src="IMG/bullet.png" alt="-" /><a href="msgs.php?user=djsoftlayer">djsoftlayer</a></li><li><IMG src="IMG/bullet.png" alt="-" /><a href="msgs.php?user=nata">nata</a></li><body style="background-image: url('IMG/bg.png')"> 

                    </ul> 
                </div> 
                <div class="content enlaces"> 
                    <h3>Deberías Visitar...</h3> 
                    <ul> 
                        <li><IMG src="IMG/bullet.png" alt="-" /> <a href="http://www.plusmusica.com">www.plusmusica.com</a> - Online jukebox!</li> 
                        <li><IMG src="IMG/bullet.png" alt="-" /> <a href="http://www.cokidoo.com">www.cokidoo.com</a> - Nuestra startup! :)</li> 
                        <li><IMG src="IMG/bullet.png" alt="-" /> <a href="http://www.cokidoo.com">www.pixelartgames.com</a> - Te gustan los juegos pixel art? ;)</li> 
                        <li><IMG src="IMG/bullet.png" alt="-" /> <a href="http://www.dmsconsulting.es">www.dmsconsulting.es</a> - Anterior empresa</li> 
                    </ul> 
                </div> 
          </div> 
        </div> 
    </div> 
    <script type="text/javascript" src="JS/tabs.js"></script> 

</body> 
</html>

最佳答案

这是您拥有的基本 html 结构

<body>  
    <div id="wrapper">
        <div id="container">
            <p>content</p>
        </div>
    </div>
</body>

这是放置横幅图片所需的基本 CSS:

    #wrapper { 
        width: 600px; /*  this is the width of your background image */
        background: url(/path/to/image.jpg); /*  this sets the div background as an image */
        margin: 0px auto; /* this centers the div */
        padding-top: 20px; /* this "pads" the div 20px on the top */
    }
    #container { 
        width: 400px;  /* this sets the width of the container, it is narrower than the wrapper div to get the effect you are looking for */
        margin: 0px auto; /* to center the div with the div#wrapper  */
    }

关于html - 背景图像标题的 CSS 和 HTML 编码建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3169856/

相关文章:

javascript - 使用表单删除 express 请求不起作用

html - 如何水平放置两个 div,其中一个是可折叠的?

css - 在 Safari、Firefox 和 Edge VS Chrome 上使用(overflow-y)滚动的 flexbox 的不同行为

javascript - wookmark 修改和 li 并排和在彼此之下

jquery - 排空时重新计算高度

javascript - 仅在选定的特定值上显示输入文本

javascript - 谷歌组织结构图 : Modify node parent

jquery - 通过 jquery 使用类时消除 Visual Studio 2008 中的 CSS 警告

javascript - 为什么重绘循环会给我的 HTML5 Canvas 起别名?

html - 如何修复 HTML 显示错误(我的文本意外下降)