clearfix

Clearfix with twitter bootstrap

≯℡__Kan透↙ 提交于 2019-12-05 08:55:02
问题 I have an issue with twitter bootstrap that looks a little bit strange to me. I have a sidebar with fixed with at the left side and a main area. <div> <div id="sidebar"> <ul> <li>A</li> <li>A</li> <li>C</li> <li>D</li> <li>E</li> <li>F</li> <li>...</li> <li>Z</li> </ul> </div> <div id="main"> <div class="clearfix"> <div class="pull-right"> <a>RIGHT</a> </div> </div> <div>MOVED BELOW Z</div> </div> #sidebar { background: red; float: left; width: 100px; } #main { background: green; margin-left:

clearfix清除浮动进化史

ぃ、小莉子 提交于 2019-12-05 03:40:22
我想大家在写CSS的时候应该都对清除浮动的用法深有体会,今天我们就还讨论下clearfix的进化史吧。 首先在很多很多年以前我们常用的清除浮动是这样的。 .clear{clear:both;line-height:0;} 现在可能还可以在很多老的站点上可以看到这样的代码,相当暴力有效的解决浮动的问题。但是这个用法有一个致命伤,就是每次清除浮动的时候都需要增加一个空标签来使用。 <p class="clear"></p> 这种做法如果在页面复杂的布局要经常清楚浮动的时候就会产生很多的空标签,增加了页面无用标签,不利于页面优化。但是我发现大型网站中 居然还在使用这种清楚浮动的方法。有兴趣的同学可以上他们首页搜索一下他们的**.blank0**这个样式名称。 因此有很多大神就研究出了 clearfix 清除浮动的方法,直接解决了上面的缺陷,不需要增加空标签,直接在有浮动的外层加上这个样式就可以了,这也是我们今天要讨论的clearfix进化史。 ##起源 .clearfix:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } .clearfix { display: inline-table; } * html .clearfix { height

响应下拉式菜单

為{幸葍}努か 提交于 2019-12-04 18:28:52
一、简介 响应式下拉菜单可在多个移动端显示会有不同的效果。 二、代码如下 <!doctype html> <html> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width"/> <title>响应式下拉菜单</title> <link rel="stylesheet" type="text/css" href="demo020.css" media="screen and (min-width:1024px)"/> <link rel="stylesheet" type="text/css" href="demo021.css" media="screen and (max-width:1024px)"/> <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"> </head> <body> <div class="nav"> <div class="toggle"> <img class="tu" src="shitu2.png"/> <i id="btn" class="fa fa-bars"></i> </div> <div class

“Best clearfix ever?”

馋奶兔 提交于 2019-12-04 09:48:23
问题 I saw this rather different method for clearfix here: http://www.marcwatts.com.au/blog/best-clearfix-ever/ It proposes adding the following CSS code which automates clearfix and does not require you to add a 'clearfix' or similar class to the elements you want to clear. /* our Global CSS file */ article:after { clear:both; content:"."; display:block; height:0; visibility:hidden; } aside:after { clear:both; content:"."; display:block; height:0; visibility:hidden; } div:after { clear:both;

CSS层叠上下文与BFC

纵饮孤独 提交于 2019-12-03 17:43:53
CSS中的层叠上下文和BFC是两个很虚但极其重要的概念,影响到网页布局的方方面面。有几篇博文讲得很详细,这里稍加摘录,便于记忆。 CSS层叠上下文 张鑫旭在 深入理解CSS中的层叠上下文和层叠顺序 里有深入的讲解: 可以创建层叠上下文的规则: z-index 值不为 auto 的flex项(父元素 display:flex|inline-flex ) 元素的 opacity 值不是 1 元素的 transform 值不是 none 元素 mix-blend-mode 值不是 normal 元素的 filter 值不是 none 元素的 isolation 值是 isolate will-change 指定的属性值为上面任意一个 元素的 -webkit-overflow-scrolling 设为 touch 需要注意的是: 如果层叠上下文元素不依赖z-index数值,则其层叠顺序是 z-index:auto ,可看成 z:index:0 级别; 如果层叠上下文元素依赖z-index数值,则其层叠顺序由 z-index 值决定。 BFC(Block Formatting Context) 梦想天空 在 BFC 神奇背后的原理 里解析得很到位: BFC直译为"块级格式化上下文"。它是一个独立的渲染区域,只有Block-level box参与, 它规定了内部的Block-level

Applying a clearfix to nth-child without additional markup

时光怂恿深爱的人放手 提交于 2019-12-03 16:34:42
First up, for extreme clarity, here a JS fiddle demonstrating what I'm trying to achieve: http://jsfiddle.net/bb_matt/VsH7X/ Here's the explanation - my rationale: I'm creating a responsive site using the 1140 grid framework. It's a fairly complex layout. I've created a re-usable simple gallery class which can drop into any defined column size & using media queries, I apply relevant percentage widths to the li elements. Each of the li elements has a right margin of 5%. I'm using nth-child(xn+x) in the media queries to remove the right margin at the end of each row. Everything works well -

HTML/CSS: Clear floating elements in the middle without adding unneeded tags

妖精的绣舞 提交于 2019-12-03 15:48:42
Most of the clearfix techniques out there involves adding things at the very bottom of the parent container, and I prefer the pseudo element approach the most since it doesn't add unneeded elements into the HTML. However, recently I found that I am dealing with a container that has some children floating but not all. Say the first 2 children the first floats left and the second floats right. I need a way to clear the float right after the second element, so the content below doesn't get squeezed in between them. Is there a way to clear floating elements in the middle but without adding

bootstrap.css: .container:before display table

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In bootstrap.css you can find either from Github or from http://twitter.github.com/bootstrap/# Why does it use: .container:before, .container:after { display: table; content: ""; zoom: 1; } .row:before, .row:after { display: table; content: ""; zoom: 1; } Why define display:table in .container:before/after and .row:before/after? 回答1: http://nicolasgallagher.com/micro-clearfix-hack/ The clearfix hack is a popular way to contain floats without resorting to using presentational markup. This article presents an update to the clearfix method that

How to solve item active and datasource part in Bootstrap carousel thumbnail for Wordpress?

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just tried to include a bootstrap powered carousal with thumbnail for my product slider. Some how I am able to do that for the main image (big image) but I am not able to fix the issues for thumbnail part. This is html version which i am trying to change to Wordpress http://codepen.io/RetinaInc/pen/rxksh The top part is now working so i tried similar approach for thumbnail slider part but couldn't fix it running the code below as it is gives syntax error so remove thumbnail part and replace it with html then main slider works. but i want

Layout using Singularity

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been trying to create a couple of typical layout examples using Singularity, and I have a question about grid-span and floats. I've created a sample scss stylesheet and html layout. Here's the complete example on Sassmeister. http://sassmeister.com/gist/a7ca98b7520b12bd6241 My question is whether the containing content div <div id="content"> is necessary? I'm having to use it with a clearfix mixin in order to 'pull' the div down and keep the footer below the content section and aside. Is there another way to achieve this layout with