Bootstrap下拉菜单失效的解决方法+使用Bootstrap制作响应式网页

article/2025/10/10 3:13:20

目录

问题原因

解决方案

顺便记录一下使用

效果图

HTML

CSS

目录


问题原因


两个js文件冲突/没有引入指定的js文件

我们不能同时引入这两个js只能引入其一,同时引入会使得部分功能失效

解决方案

注意我们使用下拉菜单时使用的js是这个

bootstrap.bundle.js

并不是

bootstrap.js

如图是正确的使用

顺便记录一下使用

效果图

下图提现了响应式

HTML

文件名 index.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><script src="../js/jquery-3.5.1.js"></script><link rel="stylesheet" href="../bootstrap/css/bootstrap.css"><script src="../bootstrap/js/bootstrap.bundle.js"></script><!--    防止bootstrap覆盖自己的样式--><link rel="stylesheet" href="../css/index.css"></head>
<body>
<img class="img_" src="../res/img/blog.jpg" alt="未加载."><!--使用container-fluid尽量撑起行 class="container-fluid"-->
<div><!--使用bg(background)来调整背景颜色--><nav class="navbar navbar-expand-lg navbar-light bg-dark  "><!--        使用offset设置行中块的横向位置(默认1行12块)从左到右--><a class="navbar-brand text-white-50 offset-1 " href="#">TMY Bolg</a><!--        实现响应式的关键 通过绑定navbarSupportedContent(被挤压内容块的id)在页面被挤压时,通过js改变页面布局 --><button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><!--            被挤压时显示出来的图标--><span class="navbar-toggler-icon bg-success"></span></button><!--        使用ml(margin-left)来调整间距--><div class="collapse navbar-collapse ml-5" id="navbarSupportedContent"><ul class="navbar-nav mr-auto"><li class="nav-item ml-4"><!--                    使用text-color设置文本颜色--><a class="nav-link text-white-50 " href="#">我的首页</a></li><li class="nav-item  ml-4"><a class="nav-link text-white-50" href="#">账号管理</a></li><li class="nav-item dropdown  ml-4"><a class="nav-link dropdown-toggle text-white-50" href="#" id="navbarDropdown" role="button"data-toggle="dropdown" aria-expanded="false">账号管理</a><div class="dropdown-menu" aria-labelledby="navbarDropdown"><a class="dropdown-item" href="#">修罗</a><a class="dropdown-item" href="#">无极</a><a class="dropdown-item" href="#">魁拔</a></div></li></ul><form class="form-inline my-2 my-lg-0"><input class="form-control mr-sm-2" type="search" placeholder="关键字" aria-label="Search"><button class="btn btn-outline-success bg-light text-dark my-2 my-sm-0" type="submit">搜索</button></form></div></nav>
</div><!--这里设置position-absolute才能使得图片在最下面-->
<!--使用栅栏布局 先重写container-fluid 使得 没有左右边距-->
<div class="container-fluid bg-light fixed-bottom row h-75 position-absolute" id="contentid">
<!--   使用col-sm布局左右两列 mt-4表示距离页面上的标签4格--><div class="col-sm mt-4">
<!--        使用弹性盒子 d-flex(display-flex) flex-column定义方向为列(盒子内的标签会竖直排列)--><div class="d-flex flex-column">
<!--            img 定义了logo class用于设置宽高圆边程度 img-thumbnail 设置边框 ml-auto mr-auto使其趋于中心 --><img class="logo img-thumbnail float-left ml-auto mr-auto" src="../res/img/Java-Logo.jpg"><h2 class="text-dark w-100 text-center">purus molestie</h2><span class="text-dark w-75 text-center ml-auto mr-auto mt-2 mb-2"> Turpis inceptos, neque vel dolor.Mauris laoreet.Purus etorci in sollicitudin,acm quam,iaculis lacus. </span><button class="btn border-dark w-25 ml-auto mr-auto">访问<span STYLE="font-size: 8px">>></span></button></div></div><div class="col-sm mt-4"><div class="d-flex flex-column bd-highlight"><img class="logo img-thumbnail  ml-auto mr-auto" src="../res/img/Java-Logo.jpg"><h2 class="text-dark w-100 text-center">nullam molestie</h2><span class="text-dark w-75 ml-auto mr-auto text-center mt-2 mb-2">Turpis inceptos,neque vel dolor. Mauris laoreet, Purus et.orci in sollicitudin. </span><button class="btn border-dark w-25 ml-auto mr-auto mt-4">访问<span STYLE="font-size: 8px">>></span></button></div></div>
</div></body></html>

CSS

文件名index.css

.img_{position:absolute;height: 100%;width: 100%;/*设置在最底层*/z-index: -2;background: rgba(255,255,255,0.1);
}
.logo{width: 200px;height: 200px;border-radius: 200px;
}
.container-fluid{padding-left: 0;padding-right: 0;margin-left: 0;margin-right: 0;margin-top: 60px;
}
#contentid{z-index: -1;
}

目录


http://chatgpt.dhexx.cn/article/jvRvxJ0V.shtml

相关文章

bootstrap使用方法以及创建bootstrap模板

创建bootstrap项目 1.进入官网进行下载 Bootstrap v3 中文文档 Bootstrap 是最受欢迎的 HTML、CSS 和 JavaScript 框架&#xff0c;用于开发响应式布局、移动设备优先的 WEB 项目。 | Bootstrap 中文网 (bootcss.com) 2.下载完成后有3个文件 3.做好以上三个文件备份后在vsco…

bootstrap使用教程

bootstrap使用教程 大家好&#xff0c;我是一枚新手前端&#xff0c;技术方面交流分享一下。接下来要给大家分享的是bootstrap这种布局方式。废话不多说&#xff0c;直接开始吧。 首先&#xff0c;第一步&#xff0c;直接在百度上面搜索”boostrap”&#xff0c;这个关键词。然…

vue引入bootstrap(两种方法)

方法一&#xff1a; &#xff08;1&#xff09;在当前项目目录下下载插件&#xff1a;bootstrap-vue npm i bootstrap-vue (2)引入到main.js并注册 import BootstrapVue from "bootstrap-vue"; Vue.use(BootstrapVue) import bootstrap/dist/css/bootstrap.css im…

bootstrap的概念使用方法

bootstrap的概念&使用方法 使用CDN引入boostrap&#xff1a; <!-- Bootstrap 核心 CSS 文件 --> <link rel"stylesheet" href"https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity"sha384-HSMxcRT…

Django 中引入bootstrap的方法

第一步&#xff0c;下载bootstrap http://v3.bootcss.com/getting-started/#download 下载第一个即可 下载压缩包之后&#xff0c;将其解压缩到任意目录即可看到以下&#xff08;压缩版的&#xff09;目录结构&#xff1a; 复制 bootstrap/ ├── css/ │ ├── boo…

bootstrap的使用方法及其基本模板

什么是Bootstrap Bootstrap来自 Twitter&#xff0c;是目前很受欢迎的前端框架。Bootstrap 是基于 HTML、CSS、JavaScript 的&#xff0c;它简洁灵活&#xff0c;使得 Web 开发更加快捷。它由Twitter的设计师Mark Otto和Jacob Thornton合作开发&#xff0c;是一个CSS/HTML框架…

BootStrap的下载及使用方法

关于BootStrap使用很简单&#xff0c;先进入它的官网http://www.bootcss.com/ 我们看上方的版本&#xff0c;这里咱们点开Bootstrap3&#xff0c;主页如图下 点击下载 下载左侧获得相关的css、javascript、font等文件&#xff0c; 这里的话&#xff0c;博主用的是3.3.5版本&am…

Spring boot使用Bootstrap

添加依赖 webjars https://www.webjars.org/ <!--引入bootstrap--> <dependency><groupId>org.webjars</groupId><artifactId>bootstrap</artifactId><version>4.0.0</version> </dependency> 查看依赖 页面引用…

BootStrap的使用(图文详解)

BootStrap的使用 ​ Bootstrap使用四步曲&#xff1a;1、创建文件夹&#xff1b;2、创建html骨架结构&#xff1b;3、引入相关样式文件&#xff1b;4、书写内容 一、创建文件夹结构 1、创建文件夹 ​ 按照以往的习惯创建文件夹。 2、下载Bootstrap ​ 在官网下载压缩包&…

Bootstrap使用

一、使用bootstrap步骤&#xff1a; 1.创建文件夹结构 2.创建html骨架结构 3.引入相关样式文件 4.书写内容&#xff08;直接用bootstrap预先定义好的样式使用 修改bootstrap原来样式&#xff0c;注意权重问题&#xff09; 要想学好bootstrap的关键在于知道它定义了哪些样式&…

“手撕“ BootStrap 方法

文章目录 Part.I IntroductionChap.I bootstrap 方法简介Chap.II 预备知识 Part.II 非参数 bootstrap 方法Chap.I 估计量标准误差的bootstrap估计Chap.II bootstrap 置信区间Chap.III bootstrap-t 法Chap.IV 一个实例 Part.III 参数 bootstrap 方法Chap.I 一个实例 Part.I Intr…

Bootstrap的基本使用方法,5分钟帮你搞懂怎么用

原文地址&#xff1a; http://blog.csdn.net/codebycoder/article/details/51001256 作为Coder&#xff0c;我们都接触过Web design&#xff0c;如何快速的构建Web应用成了我们比较头疼的一个问题&#xff0c;不仅要考虑各种浏览器的兼容性&#xff0c;同时还要考虑各种手机的…

Bootstrap的基本使用方法介绍

作为Coder&#xff0c;我们都接触过Web design&#xff0c;如何快速的构建Web应用成了我们比较头疼的一个问题&#xff0c;不仅要考虑各种浏览器的兼容性&#xff0c;同时还要考虑各种手机的页面适配&#xff0c;毕竟现在已经到了互联网手机满天飞的时代了。 我有会听嵩哥的歌…

Django中引入bootstrap的方法

一、下载bootstrap 下载地址:https://v3.bootcss.com/getting-started/#download,选择第二个,下载带有源码的bootstrap,只能通过这种方式(django是封闭的) 下载的目录结构: dist文件是bootstrap的核心文件 二、创建一个简单Demo项目 1.在根项目下创建一个static目录,再在stat…

Bootstrap基本用法

Bootstrap Bootstrap是简洁、直观、强悍的前端开发框架&#xff0c;让web开发更迅速、简单。 Bootstrap 是最受欢迎的 HTML、CSS 和 JS 框架&#xff0c;用于开发响应式布局、移动设备优先的 WEB 项目。 Bootstrap栅格系统 Bootstrap 提供了一套响应式、移动设备优先的流式栅…

BootStrap基本使用

目录 BootStrap框架 BootStrap特点 bootstrap的使用 布局容器 固定宽度 完整宽度 栅格网格系统 前言 列的形式 列组合和列偏移 列排序 列嵌套 排版 标题 段落 强调 对齐效果 列表 去点列表 内联列表 定义列表 代码 表格 表单标签 文本框和文本域 单…

统计学中的Bootstrap方法介绍及其应用

说明&#xff1a;本来这只是一篇学生时期对研究方向进行总结的文章&#xff0c;没想到能够给其他人带来了一些的帮助。两年多以来&#xff0c;有许多人留言及私信问我相关的问题&#xff0c;我也不止一次地改正文章中的一些纰漏。但限于时间久远以及水平有限&#xff0c;这篇文…

bootstrap的使用方法

Bootstrap 有趣的栅格网格系统 Bootstrap 提供了一套响应式、移动设备优先的流式栅格系统&#xff0c;随着屏幕 或视口&#xff08;viewport&#xff09;尺寸的增加&#xff0c;系统会自动分为最多 12 列。栅格系统用于通 过一系列的行&#xff08;row&#xff09;与列&#xf…

SetupFactory简单制作安装包流程

最近让我给项目做安装包&#xff0c;小白一个&#xff0c;开始找各种安装包打包工具。有的简单&#xff0c;但是功能差点意思&#xff0c;有的功能很强大&#xff0c;但是略复杂而且有的还收费。就发现SetupFactory&#xff08;安装工厂&#xff09;&#xff0c;这个工具还挺好…

setuptools的下载安装

setuptools的下载安装 *第一步&#xff0c;登录网址&#xff1a;https://pypi.org/project/setuptools/#files并下载压缩包。 第二步&#xff0c;将下载下来的压缩包解压到桌面。 第三步&#xff0c;按住shift键鼠标右键进入命令行窗口。 第四步&#xff0c;在命令行窗口输入…