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

11.编写前端内容|vscode链接Linux|html|css|js(C++)

vscode链接服务器

安装VScode插件

  • Chinese (Simplified) (简体中⽂) Language Pack for Visual Studio Code
  • Open in Browser
  • Remote SSH

在命令行输入
![[Pasted image 20250218184331.png]]

remote-ssh

接着输入
![[Pasted image 20250218184354.png]]

打开配置文件,已经配置好主机
![[Pasted image 20250218184255.png]]

点击远程资源管理器可以找到
![[Pasted image 20250218184426.png]]

右键链接
![[Pasted image 20250218184522.png]]

输入密码
![[Pasted image 20250218184727.png]]

左下角显示链接
打开文件夹
![[Pasted image 20250218184821.png]]

选择wwwroot,输入密码
![[Pasted image 20250218185025.png]]

成功打开文件
![[Pasted image 20250218185120.png]]

也可以通过终端控制

编写html
html: 是⽹⻚的⻣骼 -- 负责⽹⻚结构  
css:⽹⻚的⽪⾁ -- 负责⽹⻚美观的  
js(javascript):⽹⻚的灵魂---负责动态效果,和前后端交互

教程: https://www.w3school.com.cn/

直接在vscode上编写
![[Pasted image 20250218190047.png]]

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>boost 搜索引擎</title>
</head>
<body>
    <h1>hello, 欢迎来到我的搜索引擎</h1>
</body>
</html>

![[Pasted image 20250218190035.png]]

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>boost 搜索引擎</title>
</head>
<body>
    <div class="container">
        <div class="search">
            <input type="text" value="输入搜索关键字">
            <button>搜索一下</button>
        </div>
    </div>
</body>
</html>

![[Pasted image 20250218191633.png]]

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>boost 搜索引擎</title>
</head>
<body>
    <div class="container">
        <div class="search">
            <input type="text" value="输入搜索关键字...">
            <button>搜索一下</button>
        </div>
        <div class="result">
            <div class="item">
                <a href="#">这是标题</a>
                <p>这是摘要是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要</p>
               <i>htps://www.boost.org/doc/libs/1_78_0/doc/html/boost_dll/dependencies.html</i>
            </div>
            <div class="item">
                <a href="#">这是标题</a>
                <p>这是摘要是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要</p>
               <i>htps://www.boost.org/doc/libs/1_78_0/doc/html/boost_dll/dependencies.html</i>
            </div>
            <div class="item">
                <a href="#">这是标题</a>
                <p>这是摘要是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要</p>
               <i>htps://www.boost.org/doc/libs/1_78_0/doc/html/boost_dll/dependencies.html</i>
            </div>
            <div class="item">
                <a href="#">这是标题</a>
                <p>这是摘要是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要</p>
               <i>htps://www.boost.org/doc/libs/1_78_0/doc/html/boost_dll/dependencies.html</i>
            </div>
        </div>
    </div>
</body>
</html>

![[Pasted image 20250218192320.png]]

编写css
设置样式的本质:找到要设置的标签,设置它的属性  
1. 选择特定的标签:类选择器,标签选择器,复合选择器  
2. 设置指定标签的属性:⻅代码

将内外边距设为0

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>boost 搜索引擎</title>
    <style>
        /* 去掉网页中的所有的默认内外边距 */
        * {
            /*设置外边距 */
            margin: 0;
            /*设置内边距*/
            padding: 0;  
        }
        /*将body的内容100%和html的呈现是吻合的*/
        html,
        body {
            height: 100%;
        }
        /*类选择器*/
        .container {
            /*设置div的宽度*/
            width: 800px;
            /* 通过设置外边距达到居中对齐的目的 */
            margin: 0px auto;
            /* 设置外边距的上边距,保持元素和网页的上部距离 */
            margin-top: 15px;
        }
        /* 复合选择器,选中container下的search */
        .container .search {
            /* 宽度与父标签保持一致 */
            width: 100%;
            /* 高度设置为52像素点 */
            height: 52px;
        }
        /* 先选中input标签,直接设置标签的属性,先要选中,input:标签选择器 */
        /* input在进行高度设置的时候,没有考虑边框的问题 */
        .container .search input {
            /* 设置left浮动 */
            float: left;
            width: 600px;
            height: 50px;
            /* 设置边框属性:边框的宽度,样式,颜色 */
            border: 1px solid black;
            /* 去掉input输入框的右边框 */
            border-right: none;
            /* 设置内边距,默认文字不要紧贴左侧边框 */
            padding-left: 10px;
            /* 设置input内部的字体的颜色和样式 */
            color: #ccc;
            font-size: 20px;
        }
        .container .search button {
            /* 设置left浮动 */
            float: left;
            width: 150px;
            height: 52px;
            /* 设置button的背景颜色100,148,288 */
            background-color: #4e6ef2;
            /* 设置button中的字体颜色 */
            color: #FFF;
            /* 设置字体的大小 */
            font-size: 20px;
            font-family: Georgia, 'Times New Roman', Times, serif;
        }
        .container .result {
            width: 100%;
  
        }
        .container .result .item {
            margin-top: 15px;
        }
        .container .result .item a{
            /* 设置a为块级元素,单独占一行 */
            display: block;
            /* a标签的下划线去掉 */
            text-decoration: none;
            /* 设置a标签中的文字的字体大小 */
            font-size: 22px;
            /* 设置a标签中文字的颜色 */
            color: #4e6ef2;
        }
        .container .result .item a:hover {
            text-decoration: underline;
        }
        .container .result .item p {
            margin-top: 5px;
            font-size: 18px;
	        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
        }
        .container .result .item i {
            /* 设置a为块级元素,单独占一行 */
            display: block;
            /* 取消斜体风格 */
            font-style: normal;
            color: green;
        }
    </style>
</head>

![[Pasted image 20250218214234.png]]

编写JS

如果直接使⽤原⽣的js成本会⽐较⾼(xmlhttprequest),我们推荐使⽤JQuery.

<head>
	<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
    <script>
        function Search(){
            // 是浏览器的一个弹出框
            // alert("hello js!");
            // 1. 提取数据, $可以理解成就是JQuery的别称
            let query = $(".container .search input").val();
            conole.log("query = " + query); //console是浏览器的对话框,可以用来进行查看js数据
  
           //2. 发起http请求,ajax: 属于一个和后端进行数据交互的函数,JQuery中的
            $.ajax({
                type: "GET",
                url: "/s?word=" + query,
                success: function(data){
                    console.log(data);
                    BuildHtml(data);
                }
            });
        }
  
        function BuildHtml(data){
            // 获取html中的result标签
            let result_lable = $(".container .result");
            // 清空历史搜索结果
            result_lable.empty();
  
            for( let elem of data){
                // console.log(elem.title);
                // console.log(elem.url);
                let a_lable = $("<a>", {
                    text: elem.title,
                    href: elem.url,
                    // 跳转到新的页面
                    target: "_blank"
                });
                let p_lable = $("<p>", {
                    text: elem.desc
                });
                let i_lable = $("<i>", {
                    text: elem.url
                });
                let div_lable = $("<div>", {
                    class: "item"
                });
                a_lable.appendTo(div_lable);
                p_lable.appendTo(div_lable);
                i_lable.appendTo(div_lable);
                div_lable.appendTo(result_lable);
            }
        }
    </script>

![[Pasted image 20250219000002.png]]


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

相关文章:

  • 如何在 macOS 上配置 MySQL 环境变量
  • Linux sftp 使用详解
  • Qt的QToolButton的使用
  • 【Canvas】基础
  • golang panic信息捕获
  • jmeter接口测试(一)
  • 微服务入门-笔记
  • 汽车长期不保养的危害
  • NVIDIA和AMD显卡型号解读
  • 读书笔记:要点提炼《基于大模型的RAG应用开发与优化——构建企业级LLM应用》(严灿平)
  • 芯谷D668:便携式录音机与耳机式盒式录音机的理想音频解决方案
  • <2.20>Leetcode哈希、双指针
  • Kafka Connect 数据格式转换器
  • 微信小程序:多菜单栏设计效果
  • 基于Spring Boot的图书管理系统设计与实现(LW+源码+讲解)
  • 2025年archlinux tigervnc分辨率设置不生效的问题
  • Maven 构建报告与文档生成
  • 界面控件Telerik UI for Blazor 2024 Q4新版亮点 - 轻松实现日程自定义
  • Unity3D 使用 ILRuntime 时的性能问题详解
  • 排查生产sql查询缓慢