当前位置: 首页 > article >正文

前端知识点

下面是一个最基本的html代码

<!DOCTYPE html>
<!-- This declaration defines the document as HTML5 -->
<html lang="zh-CN">
<!-- The root element of the HTML document, with language set to Chinese (Simplified) -->

<head>
    <!-- Contains meta-information about the document -->

    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
    </style>
    <script>
        // JavaScript function that displays an alert when called
        function showMessage() {
            alert("Hello! You clicked the button.");
        }
    </script>


    <meta charset="UTF-8">
    <!-- Sets the character encoding to UTF-8 for proper text display -->

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Ensures the webpage is responsive and displays correctly on different devices -->

    <title>My First HTML Page</title>
    <!-- Defines the title of the page that appears on the browser tab -->

</head>

<body>
    <!-- Contains all the visible content of the webpage -->

    <h1>Welcome to My Page</h1>
    <!-- This is a top-level heading, typically used for the main title of the page -->

    <p>This is a simple paragraph explaining the content of this page.</p>
    <!-- Defines a paragraph of text -->

    <a href="https://www.example.com">Visit Example.com</a>
    <!-- Creates a hyperlink that users can click to visit another page -->

</body>

</html>

具体功能的实现

滑动图片的实现

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <meta name="description" content="parallax one page" />
    <meta name="keywords" content="technology, optical, silicon, spectrum, application" />

    <!-- Font Google -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,600,700,800&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Raleway:400,500,600,700&display=swap" rel="stylesheet">

    <!-- Favicon -->
    <link rel="shortcut icon" href="assets/img/favicon.ico" type="image/x-icon" />
    <link rel="icon" href="assets/img/favicon.ico" type="image/x-icon" />

    <!-- Custom styles (optional) -->
    <link href="assets/css/plugins.css" rel="stylesheet" />
    <link href="assets/css/style.css" rel="stylesheet" />

    <style>
        /* Carousel Container */
        .multi-button-container {
            display: flex;
            overflow-x: auto;
            white-space: nowrap;
            scroll-snap-type: x mandatory;
            gap: 50px;
            padding: 50px;
        }

        /* Carousel Item */
        .multi-button-box {
            flex: 0 0 auto;
            width: 300px;
            height: 400px;
            background-size: cover;
            background-position: center;
            scroll-snap-align: start;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            color: #FFFFFF;
            text-align: center;
            padding: 20px;
        }

        /* Hide scrollbar */
        .multi-button-container::-webkit-scrollbar {
            display: none;
        }

        /* Display Area for Text */
        .display-area {
            width: 90%;
            margin: 20px auto;
            padding: 20px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
            display: none;
        }

        /* Display Area Title */
        .display-area h2 {
            margin-top: 0;
        }

        /* Display Area Paragraph */
        .display-area p {
            margin: 10px 0;
        }

        /* Buttons for Scrolling */
        .scroll-button {
            background-color: #2f2e2e;
            color: #ffffff;
            border: none;
            padding: 10px;
            cursor: pointer;
            margin: 10px;
        }
    </style>
</head>

<body class="dsn-effect-scroll dsn-ajax" data-dsn-mousemove="true">

    <main class="main-root">
        <!-- Section for the Image Carousel -->
        <section class="our-work section-margin">
            <div class="container">
                <div class="one-title">
                    <div class="title-sub-container">
                        <p class="title-sub">Applications</p>
                    </div>
                    <h2 class="title-main">应用领域</h2>
                    <!-- Scroll Buttons -->
                    <button class="scroll-button" onclick="scrollContainer(-300)">上一个</button>
                    <button class="scroll-button" onclick="scrollContainer(300)">下一个</button>
                </div>
            </div>

            <!-- Image Carousel -->
            <div class="multi-button-container">
                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('智能穿戴', 'Description for 智能穿戴...')">
                    <h3>智能穿戴</h3>
                </div>

                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('化工制药', 'Description for 化工制药...')">
                    <h3>化工制药</h3>
                </div>

                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('高端医疗', 'Description for 高端医疗...')">
                    <h3>高端医疗</h3>
                </div>
                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('智能穿戴', 'Description for 智能穿戴...')">
                    <h3>智能穿戴</h3>
                </div>

                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('化工制药', 'Description for 化工制药...')">
                    <h3>化工制药</h3>
                </div>

                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('高端医疗', 'Description for 高端医疗...')">
                    <h3>高端医疗</h3>
                </div>
                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('智能穿戴', 'Description for 智能穿戴...')">
                    <h3>智能穿戴</h3>
                </div>

                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('化工制药', 'Description for 化工制药...')">
                    <h3>化工制药</h3>
                </div>

                <div class="multi-button-box" style="background-image: url('https://images.unsplash.com/photo-1725984509121-926215743c5e?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzfHx8ZW58MHx8fHx8');" onclick="showContent('高端医疗', 'Description for 高端医疗...')">
                    <h3>高端医疗</h3>
                </div>


                <!-- Add more boxes as needed -->
            </div>

            <!-- Text Display Area -->
            <div class="container">
                <div id="display-area" class="display-area">
                    <h2 id="display-title"></h2>
                    <p id="display-content"></p>
                </div>
            </div>
        </section>
    </main>

    <!-- Optional JavaScript -->
    <script src="assets/js/jquery-3.1.1.min.js"></script>
    <script src="assets/js/plugins.js"></script>
    <script src="assets/js/dsn-grid.js"></script>
    <script src="assets/js/custom.js"></script>

    <script>
        // Function to display content when an image is clicked
        function showContent(title, content) {
            var displayArea = document.getElementById('display-area');
            document.getElementById('display-title').innerText = title;
            document.getElementById('display-content').innerHTML = content;
            displayArea.style.display = 'block';
        }

        // Function to scroll the image container
        function scrollContainer(distance) {
            document.querySelector('.multi-button-container').scrollBy({ left: distance, behavior: 'smooth' });
        }
    </script>
</body>
</html>

在手机端和电脑端显示不同的图片

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<style> 
    /* Default: Show the desktop image, hide the mobile image */
.desktop-img {
    display: block;
}
.mobile-img {
    display: none;
}
/* When screen width is less than or equal to 768px, show the mobile image, hide the desktop image */
@media (max-width: 1000px) {
    .desktop-img {
        display: none;
    }
    .mobile-img {
        display: block;
    }
}
</style>
</head>
<body>
    <div class="inner-img" data-dsn-grid="move-up">
        <!-- Desktop Image -->
        <img class="desktop-img" src="https://img-home.csdnimg.cn/images/20201124032511.png" alt="">
        <!-- Mobile Image -->
        <img class="mobile-img" src="https://profile-avatar.csdnimg.cn/895333eaf40542089c36e16ba65dce84_qq_41685627.jpg!1" alt="">
    </div>
</body>
</html>

手机端效果
手机端效果
电脑端效果电脑端效果


http://www.kler.cn/a/304851.html

相关文章:

  • MySQL:CRUD
  • 【LeetCode】【算法】55. 跳跃游戏
  • 红日靶机(七)笔记
  • AI赋能电商:创新应用提升销售与用户体验
  • 吾店云介绍 – 中国人的WordPress独立站和商城系统平台
  • Visual Studio Code 端口转发功能详解
  • Apache 的CollectionUtils各种集合操作好用的方法总结
  • SQLite的入门级项目学习记录(三)
  • 鸿蒙轻内核A核源码分析系列六 MMU协处理器(2)
  • Clickhouse使用笔记
  • Linux云计算 |【第三阶段】PROJECT1-DAY3
  • 若依后端正常启动但是uniapp移动端提示后端接口异常
  • 【已解决】SpringBoot3项目整合Druid依赖:Druid监控页面404报错
  • [leetcode-python]杨辉三角2
  • 打印自身的程序
  • 如何将自己的项目发布到Maven中央仓库
  • Java面试篇基础部分-Java内部类介绍
  • ruby和python哪个好学
  • 【C++知识扫盲】------C++ 中的引用入门
  • java项目之疫情下图书馆管理系统源码(springboot)
  • 【Canvas与表盘】蓝边黑底简约表盘
  • 前端-CDN的理解及CDN一些使用平台
  • Qt 实战(10)模型视图 | 10.3、模型数据索引
  • 【网络安全】漏洞挖掘:文件上传实现Webshell
  • Qt+FFmpeg开发视频播放器笔记(三):音视频流解析封装
  • 如何制作一个自己的外卖会员卡小程序?