在屏幕中间对齐Foundation 5选项卡

编程入门 行业动态 更新时间:2024-10-28 10:33:57
本文介绍了在屏幕中间对齐Foundation 5选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图对齐的开箱即用基础5附带的标签。由于某些原因,默认情况下,它们对齐到左边,我不能弄清楚如何让这些对齐到屏幕的中心。我使用的代码相当简单(bog标准标签标记)

示例:

< ul class =tabsdata-tab> < li class =tab-title active>< a href =#panel2-1>标签1< / a>< / li& < li class =tab-title>< a href =#panel2-2>标签2< / a>< / li& < / ul> < div class =tabs-content> < div class =content activeid =panel2-1> < p>第一个面板内容到这里...< / p> < / div> < div class =contentid =panel2-2> < p>第二个面板内容到这里...< / p> < / div> < / div>

现场演示:

jsfiddle/7YxLg/

那么什么我的目标是让两个标签在屏幕中间而不是左边的中心可以这样做?

解决方案

通过以下SCSS,我获得了标签中心和基础:

ul.tabs { text-align:center; li { float:none!important; display:inline-block; } }

如果使用纯CSS:

ul.tabs { text-align:center; } ul.tabs li { float:none!important; display:inline-block; }

好处:宽度,这可能导致响应性的问题。你也不需要一个额外的div。

到ul的css将中心li元素。但是,Foundation的默认CSS增加了float:left到li的里面ul.tabs。我们用float:none!来清除这个,重要的是在一个内联块中重新对齐li元素。

Im trying to align the out of the box Tabs which come with Foundation 5. For some reason by default they are aligned to the left and i cant figure out how i can get these to align to the center of the screen. The code i am working with is fairly simple (the bog standard tab markup)

Example:

<ul class="tabs" data-tab> <li class="tab-title active"><a href="#panel2-1">Tab 1</a></li> <li class="tab-title"><a href="#panel2-2">Tab 2</a></li> </ul> <div class="tabs-content"> <div class="content active" id="panel2-1"> <p>First panel content goes here...</p> </div> <div class="content" id="panel2-2"> <p>Second panel content goes here...</p> </div> </div>

Live Demo:

jsfiddle/7YxLg/

So what i am aiming for is for the two tabs to be centered in the middle of the screen instead of to the left can this be done?

解决方案

I got the tabs to center and play nice with foundation through the following SCSS:

ul.tabs { text-align: center; li { float: none !important; display: inline-block; } }

If you're using plain CSS:

ul.tabs { text-align: center; } ul.tabs li { float: none !important; display: inline-block; }

Benefits: You don't need to specify a width, which can cause problems with responsiveness. You also don't need an extra div. This solution is specific to foundation as well.

Explaination: Normally, adding text-align: center; to the ul's css would center the li elements. But, foundation's default css adds float: left to li's inside ul.tabs. We clear this with float: none !important and realign the li elements in an inline block.

更多推荐

在屏幕中间对齐Foundation 5选项卡

本文发布于:2023-10-12 21:47:32,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项卡   屏幕   Foundation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!