gpt4 book ai didi

css - 图像未显示在 html 中

转载 作者:行者123 更新时间:2023-11-28 15:16:09 25 4
gpt4 key购买 nike

在网页设计方面,我完全是个菜鸟。我刚开始学习一些基础知识。目前我正在尝试使图像成为我网页的标题横幅。我看过很多教程,每个教程都说要使用代码 <img src="images/wood.jpg" height="168" width="100">如果您在网页目录中有一个专门用于图像的文件,并使用高度和宽度说明符使其适合横幅的范围。话虽如此,我刷新页面并且没有显示图像。还有关于如何使文字叠加在图像上的信息的奖励积分。

                <!DOCTYPE HTML>
<!--- COMMENT--->


<html long="en">


<head>

<meta charset="UTF -8"/>
<Title>Ken's Woodworking Emporium</title>
<link rel="stylesheet" type="text/css" href="style.css">
<!--[if lt IE 9]>
<script>
document.createElement("article");
document.createElement("aside");
document.createElement("footer");
document.createElement("header");
document.createElement("main");
document.createElement("nav");
document.createElement("section");
</script>
<![endif]-->

<meta name="description" contents= "Learn everything you want to know
about wood working."/>

<meta name="keyword" content=html5 canvas,html5,toutorial,html5 doctype,
video, learn/>

<meta name="robots" Content="index, follow"/>

<base href="http://localhost/html/"/>

<link rel= stylesheet" href="styles.css"/>


</head>

<body>
<header class="banner">
<h1>Woodworking</h1>
<img src="images/wood.jpg">
<p> Local woodworkers</p>
</header>

<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="archive.html">Archive</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>

<main>
<section>
<h2>Carpenty</h2>
<article>
<header>
<h3>Details on carpentry</h3>
<p>(Author, date)</p>
</header>
<p>THis is the story text.This is the story text.</p>
<p>This is the story text.This is the story text.</p>
</article>
</section>

<section>
<article>
<header>
<h3>Custom carpentry.</h3>
<p>(Author, date)</p>
</header>
<p>THis is the story text.This is the story text.</p>
<p>This is the story text.This is the story text.</p>
</article>
</section>

<section>
<h2>Restoration</h2>
<article>
<header>
<h3>Old to new</h3>
<p>(Author, date)</p>
</header>
<p>THis is the story text.This is the story text.</p>
<p>This is the story text.This is the story text.</p>
</article>
</section>

<section>
<article>
<header>
<h3>refinishing.</h3>
<p>(Author, date)</p>
</header>
<p>THis is the story text.This is the story text.</p>
<p>This is the story text.This is the story text.</p>
</article>
</section>
</main>

<aside>
<h2>Have a request?</h2>
<p>If you have a custom order request feel free to contact us at 918-555-5555, or ABC123@yahoo.com</p>
</aside>

<footer>
<p>Footer information</p>
</footer>

</body>



</html>

最佳答案

如果您希望横幅图片作为其他元素的背景,而不是使用 img 标签,您可以尝试使用 background-image CSS 属性。我对您的样式表一无所知,因此尽可能简单明了。

我给你做了一个小例子@ https://jsfiddle.net/wck2hyxt/1/

HTML:

        <body>
<header class="banner">
<h1>Woodworking</h1>
<p> Local woodworkers</p>
</header>
</body>

CSS:

header.banner {
background-image:url("https://upload.wikimedia.org/wikipedia/commons/b/b3/Campania_banner_View_from_Capri.jpg");
background-size: cover;
height: 168px;
width: 100%;
padding: 10px;
}

注意:我为横幅使用了外部图像。您可以将该网址更改为“/path/to/image”。另外,我相信您的意图是使宽度为 100%,而不仅仅是 100。

关于css - 图像未显示在 html 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43357390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com