博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何使用Twitter Bootstrap获得中心内容?
阅读量:2288 次
发布时间:2019-05-09

本文共 2747 字,大约阅读时间需要 9 分钟。

本文翻译自:

I'm trying to follow a very basic example. 我试图遵循一个非常基本的例子。 Using the , I was hoping the following: 使用 ,我希望以下内容:

Bootstrap starter template

Example text.

...would produce centered text. ......会产生中心文本。

However, it still appears on the far left. 但是,它仍然出现在最左边。 What am I doing wrong? 我究竟做错了什么?


#1楼

参考:


#2楼

The best way to do this is define a css style: 最好的方法是定义一个css样式:

.centered-text {    text-align:center}

Then where ever you need centered text you add it like so: 然后你需要居中的文本,你可以像这样添加它:

Bootstrap starter template

Use this document as a way to quick start any new project.

All you get is this message and a barebones HTML document.

or if you just want the p tag centered: 或者如果你只想让p标签居中:

Bootstrap starter template

Use this document as a way to quick start any new project.

All you get is this message and a barebones HTML document.

The less inline css you use the better. 你使用的内联css越少越好。


#3楼

If you are using Bootstrap 2.0+ 如果您使用的是Bootstrap 2.0+

This can make the div centered to the page. 这可以使div以页面为中心。

//your content here gets centered of the page

#4楼

Any text-align utility class would do the trick. 任何文本对齐实用程序类都可以解决问题。 Bootstrap has been using .text-center class for centering text for a long time now. Bootstrap已经使用.text-center类来长时间居中文本了。

.text-center { text-align: center !important; }

Or you can create your own utilities. 或者您可以创建自己的实用程序。 Some variations I've seen over the years: 我多年来看到的一些变化:

.u-text-center { text-align: center !important; }.ta-center { text-align: center !important; }.ta\:c { text-align: center !important; }

#5楼

NOTE: this was . 注意:这被 。


Pre-Bootstrap 3, you could use the CSS class pagination-centered like this: Pre-Bootstrap 3,你可以使用CSS类pagination-centered如下所示:

Centered content.

Class pagination-centered is already in bootstrap.css (or bootstrap.min.css) and has the only one rule: pagination-centered类已经在bootstrap.css(或bootstrap.min.css)中并且只有一个规则:

.pagination-centered{text-align:center;}

With Bootstrap 2.3.0. 使用Bootstrap 2.3.0。 just use class text-center 只需使用类text-center


#6楼

On my side I define new CSS styles ready to use and easy to remember: 在我这边,我定义了可以使用且易于记忆的新CSS样式:

.center { text-align: center;}.left { text-align: left;}.right { text-align: right;}.justify { text-align: justify;}.fleft { float: left;} /*-> similar to .pull-left already existing in bootstrap*/.fright { float: right;}  /*-> similar to .pull-right already existing in bootstrap*/.vab { vertical-align: bottom;}.bold { font-weight: bold;}.italic { font-style: italic;}

Is it a good idea? 这是个好主意吗? Is there any good practice for this? 这有什么好的做法吗?

转载地址:http://dicnb.baihongyu.com/

你可能感兴趣的文章
算法题汇总
查看>>
linux user namespace 和cgroup
查看>>
linux内核内存读写属性更改的问题
查看>>
Ftrace跟踪内核
查看>>
linux 内核启动
查看>>
linux 内核中的Makefile
查看>>
内核进程管理启动rest_init
查看>>
xposed流程图解析
查看>>
linux 进程切换
查看>>
elf 格式分析----函数解析
查看>>
内核漏洞利用方法
查看>>
CVE-2018-18955user_name_space空间越权漏洞
查看>>
CVE-2019-11815内核竞态漏洞推测
查看>>
内联jmp使用方法
查看>>
VT技术和kvm
查看>>
sudo 控制权限原理
查看>>
linux信号处理
查看>>
dwarf 栈解析格式小结
查看>>
kvm 监控内存,替换页表(linux版的win VT晶核)(这个整复杂了,不用小内核也可以实现,留着吧,主要记录了bootLoad的启动过程)
查看>>
KVM 代码详解
查看>>