简体   繁体   English

HTML & CSS 代码在我的实际项目中没有显示相同的 output,我已经在另一个单独的 html 文件中修复了

[英]The HTML & CSS code is not showing the same output in my actual project, that I have fixed in another separate html file

I would like to make my output of the Html and CSS file like this (ss#1);我想像这样制作 Html 和 CSS 文件的 output (ss#1); I've created this using a separate HTML and CSS file, but when I'm putting it on my actual Html and CSS file it turns out to be like this (ss#2).我使用单独的 HTML 和 CSS 文件创建了它,但是当我将它放在我实际的 Html 和 CSS 文件中时,结果是这样的 (ss#2)。 How can I fix this?我怎样才能解决这个问题?

Here is the source code for ss#1这是 ss#1 的源代码

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <title>Swiper demo</title>
        <meta
          name="viewport"
          content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
        />
        <!-- Link Swiper's CSS -->
        <link
          rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css"
        />

        <!-- Demo styles -->
        <style>
          html,
          body {
            position: relative;
            height: 100%;
          }

          body {
            margin: 0;
            padding: 0;
          }

          html,
          body {
            position: relative;
            height: 100%;
          }

          body {
            display: flex;
            justify-content:center;
            align-items:center;
          }

          .swiper {
            width: 200px;
            padding-top: 200px;
            padding-bottom: 0;
          }

          .swiper-slide {
            display: flex;
            align-items:center;
            justify-content: center;
            border-radius: 15px;
          }
          .swiper-slide img{
            display:flex;
            width: 100%;
          }
        </style>
      </head>

      <body>
        <!-- Swiper -->

        <div class="swiper mySwiper">
          <div class="swiper-wrapper">
            <div class="swiper-slide">
                <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img4.JPG" />
            </div>
            <div class="swiper-slide">
                <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img1.JPG" />
            </div>
            <div class="swiper-slide">
                <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img11.jpeg" />
            </div>
            <div class="swiper-slide">
                <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img7.jpeg" />
            </div> 
            <div class="swiper-slide">
                <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img10.png" />
            </div> 
          </div>
        </div>

        <!-- Swiper JS -->
        <script src="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.js"></script>

        <!-- Initialize Swiper -->
        <script>
          var swiper = new Swiper(".mySwiper", {
            effect: "cards",
            grabCursor: true,
            spaceBetween: 30,
            centeredSlides: true,
            autoplay: {
              delay: 2500,
              disableOnInteraction: false,
            },
            pagination: {
              el: ".swiper-pagination",
              clickable: true,
            },
          });
        </script>
      </body>
    </html>

<!-- end snippet -->

here is the source code for ss#2这是 ss#2 的源代码

<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta
            name="viewport"
            content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
        />
        <title>Instant Resume Builder</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css">
        <script src="https://kit.fontawesome.com/f5ba79b0f3.js" crossorigin="anonymous"></script>
        <link href="https://fonts.googleapis.com/css2?family=Josefin+Sans&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css">
        <link rel="stylesheet" href="style.css">

        <style>
            section{
    position: absolute;
    width: 100px;
    min-height: 20vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin: 0.50%;
    padding: 0.50%;
}

.swiper {
  width: 100%;
  padding-top: 120px;
  padding-bottom: 0;
}

.swiper-slide {
  display: flex;
  align-items:center;
  justify-content: center;
  border-radius: 15px;
  width: 100%;
  height: 100%;
}
.swiper-slide img{
  display:flex;
  width: 100%;
}
        </style>
    </head>

    <body>
        <div class="main">
            <div class="logo">
                <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/logo.png">
            </div>

            <div class="section">
            
            <!-- Swiper -->

            <div class="swiper mySwiper">
                <div class="swiper-wrapper">
                <div class="swiper-slide">
                    <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img4.JPG" />
                </div>
                <div class="swiper-slide">
                    <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img1.JPG" />
                </div>
                <div class="swiper-slide">
                    <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img11.jpeg" />
                </div>
                <div class="swiper-slide">
                    <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img7.jpeg" />
                </div> 
                <div class="swiper-slide">
                    <img src="/Users/megatron/Documents/Project/ResumeBuilder/images/img10.png" />
                </div> 
                </div>
            </div>
            </div>
            
            <!-- Swiper JS -->
            <script src="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.js"></script>

            <!-- Initialize Swiper -->
            <script>
            var swiper = new Swiper(".mySwiper", {
                effect: "cards",
                grabCursor: true,
                spaceBetween: 30,
                centeredSlides: true,
                autoplay: {
                delay: 2500,
                disableOnInteraction: false,
                },
                pagination: {
                el: ".swiper-pagination",
                clickable: true,
                },
            });
            </script>
        </div>
    </body>
</html>

在此处输入图像描述

在此处输入图像描述

If you are using VS Code I think I can help.如果您使用的是 VS Code,我想我可以提供帮助。 First of all, before pasting the style code, come to the beginning without any tab space and paste it there.首先,在粘贴样式代码之前,来到开头没有任何制表符的位置并将其粘贴到那里。 Then after selecting the whole style code, you can adjust it by pressing the tab / shift + tab keys.然后选择整个样式代码后,您可以通过按tab / shift + tab键进行调整。

Also, as I said at the beginning, if you are using VS code, you can try to install and adjust the Prettier plugin.另外,正如我开头所说,如果你使用的是VS code,你可以尝试安装和调整Prettier插件。 (Format on save feature must be turned on in settings) This could also be a solution. (必须在设置中打开保存格式功能)这也可能是一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的 css html 代码有错误如何修复 - i have error in my css html code how fix 使用 jquery 注入 HTML 和 CSS 但有 Z2C56C360580420D293172FB2 单独文件? - Inject HTML and CSS using jquery but have the CSS in a separate file? 我在使用外部 CSS 文件设置 HTML 表格样式时遇到问题 - I have a problem in styling my HTML table with external CSS file 如何将 CSS 和 HTML 代码放在同一个文件中? - How can I put CSS and HTML code in the same file? 如何在 HTML 中将不同的文本位放在同一行而不影响彼此? - How do I have separate bits of text in HTML on the same line without them affecting one-another? Dojo转换到同一项目中的另一个html文件 - Dojo transition to another html file in same project 当我在谷歌浏览器上打开开发人员工具时,为什么我的 css 代码文件有我的 html 源代码? - Why does my css code file have my html source when I open developers tool on google chrome? 在 html 或 css 中我的代码有问题 - In html or in css I have a problem with the code 单独的css文件在html文件上不起作用,但是将css与html放在同一文件中 - separate css file does not work on html file but put css in the same file as the html works 尝试在单独的 JS 文件中调用 PHP 脚本,如何将输出显示到我的 HTML 页面上 - Trying to call a PHP script in separate JS file, how do i display the output onto my HTML page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM