GVKun编程网logo

html – 文本与bootstrap的navbar-text pull-right无法正确对齐(文本与html需要用什么符号连接?)

27

最近很多小伙伴都在问html–文本与bootstrap的navbar-textpull-right无法正确对齐和文本与html需要用什么符号连接?这两个问题,那么本篇文章就来给大家详细解答一下,同时本

最近很多小伙伴都在问html – 文本与bootstrap的navbar-text pull-right无法正确对齐文本与html需要用什么符号连接?这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展Bootstrap .navbar-text类、Bootstrap Navbar无法正常工作:AngularCLI、bootstrap-4 – Bootstrap 4:当在nav.navbar中时,下拉菜单没有右对齐、Bootstrap3基础 text-right/left/center 设置标题右对齐、左对齐、居中等相关知识,下面开始了哦!

本文目录一览:

html – 文本与bootstrap的navbar-text pull-right无法正确对齐(文本与html需要用什么符号连接?)

html – 文本与bootstrap的navbar-text pull-right无法正确对齐(文本与html需要用什么符号连接?)

我在html文件中有以下代码:

 

我得到这样的输出:

请注意,“这是第二次通知”与其上方的行没有正确对齐.我试图让两个通知彼此正确对齐.

我也尝试删除< br />从上面的代码,但我得到以下输出:

有人可以指出我做错了什么吗?

JSFiddle:http://jsfiddle.net/N6vGZ/23/

最佳答案
两个段落在导航栏中没有正确对齐的原因是因为bootstraps提出的默认行高40px不允许它们都正确堆叠.您可以通过设置较低的行高来解决这个问题,像20px这样的东西应该可以解决问题.

注意:我在容器中包含了两个段落,我可以轻松地浮动并使用我自己的类进行定位,以免打扰周围的其他元素.

HTML

试试这个:

CSS

.notices p {
    line-height:20px !important;
}

演示:http://jsfiddle.net/N6vGZ/29/

Bootstrap .navbar-text类

Bootstrap .navbar-text类

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = /bootstrap/css/bootstrap.min.css rel = stylesheet>
      <script src = /scripts/jquery.min.js></script>
      <script src = /bootstrap/js/bootstrap.min.js></script>
   </head>
   <body>
      <nav class = navbar navbar-default role = navigation>
         <div class = navbar-header>
            <a class = navbar-brand href = #>Demo</a>
         </div>
         <div>
            <p class = navbar-text>copyright © 2018</p>
         </div>
      </nav>
   </body>
</html>

Bootstrap Navbar无法正常工作:AngularCLI

我将bootstrap包含在我的angularcli项目中,但是当我尝试包含导航栏时,没有任何元素正常工作.我在网站上使用标准的boostrap导航栏示例,但它看起来很奇怪:

我的项目导致导航栏无法正确加载有什么问题?

navbar.component.html

<nav>
  <buttontype="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span></span>
  </button>
  <ahref="#">Navbar</a>

  <divid="navbarSupportedContent">
    <ul>
      <li>
        <ahref="#">Home <span>(current)</span></a>
      </li>
      <li>
        <ahref="#">Link</a>
      </li>
      <li>
        <ahttps://www.jb51.cc/tag/dis/" target="_blank">disabled" href="#">disabled</a>
      </li>
    </ul>
    <form>
      <inputtype="text" placeholder="Search">
      <buttontype="submit">Search</button>
    </form>
  </div>
</nav>

.angular-cli.json

"styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css","styles.css"
      ],

解决方法

bootstrap 4中存在一些已知问题,尤其是在navbar实现中

因此你必须安装bootstrap bootstrap@3.3.7

如果您使用的是npm,那么最好推荐以下库

npm install bootstrap@3.3.7 --save

npm install bootstrap@3.3.7 tether jquery --save

在.angular-cli.json文件中添加依赖项

"styles":[
"styles.css","../node_modules/bootstrap/dist/css/bootstrap.css"
],"scripts":[
"../node_modules/jquery/dist/jquery.js","../node_modules/tether/dist/js/tether.js","../node_modules/bootstrap/dist/js/bootstrap.js"
],

使用以下HTML

<nav>
    <div>
    <div>
    <button type="button"data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
    <span>Togglenavigation</span>
    <span></span>
    <span></span>
    <span></span>
    </button>
    <ahref="#">Angular5Website</a>
    </div>
    <div id="navbar">
    <ul>
    <li> <a href="#">Home</a></li>
    <li><a href="#about">About</a></li>
    <li><a href="#contact">Contact</a></li>
    </ul>
    </div><!--/.nav-collapse-->
    </div>
    </nav>

bootstrap-4 – Bootstrap 4:当在nav.navbar中时,下拉菜单没有右对齐

bootstrap-4 – Bootstrap 4:当在nav.navbar中时,下拉菜单没有右对齐

从CDN加载最新的Boostrap 4和popper.js.

Codepen here.

问题.

我的下拉代码:

<div>
    <button type="button"data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">This dropdown''s menu is right-aligned</button>
    <div>
        <buttontype="button">Action</button>
        <buttontype="button">Another action</button>
        <buttontype="button">Something else here</button>
    </div>
</div>

我把它放在里面< nav class =“navbar”>它是正确的:

<nav>
  <ahref="#">Navbar</a>
  <buttontype="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span></span>
  </button>

  <divid="navbarSupportedContent">
    <div>
        <button type="button"data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Welcome</button>
        <div>
            <buttontype="button">Action</button>
            <buttontype="button">Another action</button>
            <buttontype="button">Something else here</button>
        </div>
    </div>
  </div>
</nav>

问题是,当您单击“欢迎”时,下拉菜单会出现在屏幕的右边缘之外,尽管下拉菜单右侧是类.

提议的解决方案here不起作用({margin:0}没有帮助).

题.

如何确保下拉不会超出屏幕的右边缘?

谢谢!

解决方法

我也没有那个工作过.但是,我正在使用的解决方法到目前为止解决了所有问题:

.dropdown-menu-right {
    right:0;
    left:auto;
}

Bootstrap3基础 text-right/left/center 设置标题右对齐、左对齐、居中

Bootstrap3基础 text-right/left/center 设置标题右对齐、左对齐、居中

?

内容
参数
??OS ??Windows 10 x64
??browser ??Firefox 65.0.2
??framework?? ??Bootstrap 3.3.7
??editor ??Visual Studio Code 1.32.1??
??typesetting ??Markdown

?

code

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <Meta charset="UTF-8">
    <!-- IE将使用最新的引擎渲染网页 -->
    <Meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 页面的宽度与设备屏幕的宽度一致
         初始缩放比例 1:1 -->
    <Meta name="viewport" content="width=device-width,initial-scale=1">

    <title>Demo</title>
    <Meta name="author" content="www.cnblogs.com/kemingli">

    <!-- 引入外部bootstrap的css文件(压缩版),版本是3.3.7 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询(media queries)功能 -->
    <!-- 警告:通过 file:// 协议(就是直接将 html 页面拖拽到浏览器中)访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html5shiv.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dest/respond.min.js"></script>
    <![endif]-->
</head>

<body>

    <!-- start : demo -->
    <div>
        <h1>右对齐</h1>
        <h1>左对齐</h1>
        <h1>居中</h1>
    </div>
    <!-- end : demo -->

    <!-- NO.1 加载框架依赖的jQuery文件(压缩版),版本是1.12.4 -->
    <script src="bootstrap/js/jquery.min.js"></script>
    <!-- NO.2 加载Bootstrap的所有JS插件,版本是3.3.7 -->
    <script src="bootstrap/js/bootstrap.min.js"></script>
</body>

</html>

?

result

分享图片

?

resource

  • [ 文档 ] getbootstrap.com/docs/3.3
  • [ 源码 ] github.com/twbs/bootstrap
  • [ 源码 ] archive.mozilla.org/pub/firefox/releases/65.0/source/
  • [ 平台 ] www.cnblogs.com
  • [ 平台 ] github.com
  • [ 扩展 - 平台] www.bootcss.com
  • [ 扩展 - 浏览器 ] www.mozilla.org/zh-CN/firefox/developer

?

Bootstrap是前端开源框架,优秀,值得学习。 博文讲述的是V3版本,更为先进的是V4版本。学有余力的话,可作简单地了解。 Firefox是开源的浏览器,优秀,值得关注。 面对开源框架,分析、领悟与应用,能对其进行加减裁化,随心所欲而不逾矩。 博文的质量普通,仅供参考。盲目复制,处处是坑。Think twice before you act(三思而后行)!

我们今天的关于html – 文本与bootstrap的navbar-text pull-right无法正确对齐文本与html需要用什么符号连接?的分享就到这里,谢谢您的阅读,如果想了解更多关于Bootstrap .navbar-text类、Bootstrap Navbar无法正常工作:AngularCLI、bootstrap-4 – Bootstrap 4:当在nav.navbar中时,下拉菜单没有右对齐、Bootstrap3基础 text-right/left/center 设置标题右对齐、左对齐、居中的相关信息,可以在本站进行搜索。

本文标签:

上一篇html – 将div附加到另一个div的右侧(html将div放到指定位置)

下一篇html – fieldset元素的name属性有什么作用?(html中field属性)