html - 如何修复使用 CSS 渲染时图像模糊的问题?

标签 html css image-size

我收到了一些关于过去作业的反馈,警告我图像模糊。但我无法弄清楚如何解决它。作业非常清楚地描述了要做什么,但我做了它要求的一切。

我必须对图像执行以下操作:

Add a new selector id named yurthero. In CSS code declarations to configure 300px height and to display the coast.jpg background image to fill the space(use background-size: 100% 100%;) without repeating.

如何防止图像模糊?在我看来,拉伸(stretch)迫使它变得模糊。

下面附上了我正在使用的 html5、css3 和图像。 coast.jpg

/* pacific.css for assignment #3 by Caleb Latimer */
body{
      background-color: #FFFFFF;
      color : #666666;
      font-family: Verdana;
      background-image: url(background.jpg);
}
h1{
      background-color: #000033;
      color : #FFFFFF;
      font-family: Georgia;
      line-height: 200%;
      background-image: url(sunset.jpg);
      background-repeat: no-repeat;
      padding-left: 20px;
      height: 72px;
      margin-bottom: 0;
      background-position: right;
}
nav{
      font-weight: bold;
      background-color: #90C7E3;
      padding: 5px 5px 5px 5px;
}
h2{
      color: #3399CC;
      font-family: Georgia;
}
dt{
      color: #000033;
      font-weight: bold;
}
.resort{
      color: #000033;
      font-size: 1.2em;
}
footer{
      font-size: .70em;
      font-style: italic;
      text-align: center;
      padding: 10px 10px 10px 10px;
}
#wrapper{
      width: 80%;
      margin-right: auto;
      margin-left: auto;
      background-color: #ffffff;
      min-width: 700px;
      max-width: 1024px;
      box-shadow: 5px 5px 5px #828282;
}
h3{
      color: #000033;
}
main{
      padding-left: 20px;
      padding-right: 20px;
      display:block;
}
#homehero{
      background-size: 100% 100%;
      height: 300px;
      background-image: url(coast.jpg);
      background-repeat: no-repeat;
}
#yurthero{
      height: 300px;
      background-image: url(yurt.jpg);
      background-size: 100% 100%;
      background-repeat: no-repeat;
}
#trailhero{
      height: 300px;
      background-image: url(trail.jpg);
      background-size: 100% 100%;
      background-repeat: no-repeat;
}
nav a{
      text-decoration: none;
}
<!-- Chapter 4 Homework by Caleb Latimer -->
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="utf-8">
    <title>Pacific Trails Resort</title>
    <link rel="stylesheet" href="pacific.css" /> <!-- Uses the pacific.css stylesheet inside of folder -->
  </head>
  <body>
        <div id="wrapper">
             <header>
                     <h1>Pacific Trails Resort</h1>
             </header>

          <nav>
            <a href="index.html">Home</a>
            &nbsp;
            <a href="yurts.html">Yurts</a>
            &nbsp;
            <a href="activities.html">Activities</a> 
            &nbsp;
            <a href="reservations.html">Reservations</a> <!-- Doesn't lead anywhere no requirements given -->
          </nav>

          <div id ="homehero"></div>
          <main>
            <h2>Enjoy Nature in Luxury</h2>

            <p>
              <span class="resort">Pacific Trails Resort</span> offers a special lodging experience on the California North Coast. Relax in serenity with panoramic views of the Pacific Ocean.
            </p>

            <ul>
              <li>Private yurts with decks overlooking the ocean</li>
              <li>Activities lodge with fireplace and gift shop</li>
              <li>Nightly fine dining at the Overlook Cafe</li>
              <li>Heated outdoor pool and whirlpool</li>
              <li>Guided hiking tours of the redwoods</li>
            </ul>

            <div>
              <span class="resort">Pacific Trails Resort</span> <br />
              12010 Pacific Trails Road <br />
              Zephyr, CA 95555<br /><br />
              888-555-5555<br />
            </div>

          </main>

          <footer>
            Copyright &copy; 2016 Pacific Trails Resort <br />
            <a href = "mailto:Caleb@Latimer.com">Caleb@Latimer.com</a>
          </footer>
        </div>
  </body>
</html>

最佳答案

好吧,事实证明我在作业中收到了错误的图片。使用正确的图片,它们会按预期结果出现。始终检查图像的大小、高度和宽度尺寸。

关于html - 如何修复使用 CSS 渲染时图像模糊的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42241078/

相关文章:

html - Bootstrap 3 中的奇怪按钮包装 - 响应式设计

Javascript 打印多行变量

html - CSS 不能在不同的机器上工作

html - 表格行在第一列内得到调整

css - 我如何知道我应该在响应式网站上的图像上设置什么宽度/高度?

css - Wordpress: Logo 在小屏幕上的尺寸非常小

javascript - 在悬停和移出时切换滚动 DIV 内容

css - 使用@import编译sass时报错 "Invalid UTF-8"

javascript - 如何在响应中将 div 移动到另一个 in 中?

jquery - 图像不会随 div 容器/窗口改变大小