首页 > 解决方案 > 如何在正确的内容页面上打开图像

问题描述

我正在尝试从侧边栏打开图像到右侧面板。它需要保持在同一页面上。

例如像这样的东西。https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_sidebar

假设链接 1 和链接 2 和链接 3 是图像,通过单击其中一个,我希望图像显示在您看到“我的页面”的右侧。

<!DOCTYPE html>
<html>
  <title>W3.CSS</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  <body>

    <!-- Sidebar -->
    <div class="w3-sidebar w3-light-grey w3-bar-block" style="width:25%">
      <h3 class="w3-bar-item">Menu</h3>
      <a href="img_car.jpg" class="w3-bar-item w3-button">Link 1</a>
      <a href="#" class="w3-bar-item w3-button">Link 2</a>
      <a href="#" class="w3-bar-item w3-button">Link 3</a>
    </div>

    <!-- Page Content -->
    <div style="margin-left:25%">

      <div class="w3-container w3-teal">
        <h1>My Page</h1>
      </div>

      <img src="img_car.jpg" alt="Car" style="width:100%">

      <div class="w3-container">
        <h2>Sidebar Navigation Example</h2>
        <p>The sidebar with is set with "style="width:25%".</p>
        <p>The left margin of the page content is set to the same value.</p>
      </div>

    </div>

  </body>
</html>

标签: htmlcss

解决方案


推荐阅读