
You may read the rest of my article, which was published on Wednesday, April 11th 2007. Here it comes: When you’re creating a theme for Drupal, you have two tricks at your disposal to deal with floats, each trick aimed at one particular float ‘problem’.
The first challenge you may encounter is to prevent ‘spilling’ of floated elements out of their container. You may want to force a container element to stretch out... to wrap around all floated elements it contains. Here’s what I am talking about :
If someone holds a gun to my head, maybe I will finish my first Drupal theme before the end of the month.
The method at your disposal to fix this problem is to add the class “clear-block” to the container element. The class is defined in modules/system/defaults.css. That’s ‘core’ CSS. It’s ready to use whenever you need it. And you’re done. You no longer need to worry about floated elements spilling out. The method used in defaults.css is inspired (or borrowed directly) from a solution proposed on the website Position is everything. It works in all commonly used browsers, even those less common ones. It requires no markup, but does involve 2 hacks. Here’s the same div with a “clear-block” applied :
If someone holds a gun to my head, maybe I will finish my first Drupal theme before the end of the month.
Here is the CSS for the “clear-block” class :
The :before and :after pseudo-elements, selector:before and selector:after, are used to insert generated content before or after an element’s content. These specific pseudo-elements are not supported in Internet Explorer 7 or below.
Second method is the “rubber-band” trick. You may apply that trick whenever you wish to (using a figure of speech) place a horizontal invisible line to keep elements that are in the markup that precedes, above ; and what comes after that markup, below. For that, you insert the following <span> element where you want your rubber band to be (imagine a rubber band tightly tied at both left and right ends) :
However, if you do that, you have to define the clear class in your theme’s style.css file. That’s easy : copy and paste the CSS rule span.clear from garland’s style.css file to your theme’s stylesheet (your own style.css).
Now I may force the paragraph that follows the following spilling <div> to drop below my rubber band. I will place my rubber band, that is, my <span> element, between my spilling div and the next paragraph. Just watch me.
If someone holds a gun to my head, maybe I will finish my first Drupal theme before the end of the month.
See ? It’s that easy. Do a View Source in your browser. This paragraph (right here!) is not creeping up along the right end side of the image that is spilling out of its box. It’s held below an invisible line, kept under our “rubber band”.
Why are we using a <span> for our rubber band if we’re setting its CSS display property to “block” ? you may ask. Why not use a <div> instead ? We could. We may use whatever will give us valid XHTML, a span or a div. A span goes just about anywhere, while a div does not. For example, a paragraph can only contain inline elements in XHTML strict. So we’ll use a span in that paragraph, and make it a block in the CSS, using the CSS rule exactly as it is defined above. On the other hand, we cannot put any inline elements right under the <body> element. So, in that particular situation, we will use a <div> rubber band, if we require one. But in most other cases, a <span> will do.
Update [April 17th] : I just read rumors on the Net according to which a <div> rubber band in IE5 and IE6 can produce several nasty bugs in “certain conditions”.
Attached to this posting is a zip that contains two HTML files with a common stylesheet. Each document is a demonstration of a trick. If you’re not using Drupal, then download this demo, it contains all the CSS you will need to solve the problems described in this article.
| Attachment | Size | Hits | Last download |
|---|---|---|---|
| problems-with-float-fixed.zip | 33.78 KB | 23 | 4 years 18 weeks ago |
Comments
HR
Whenever I need the "rubber-band" trick I use a HR instead of a span. It's a bit more oh-so-semantic and useful when people have disabled styles for some reason.
A hr occupies space
A line occupies some space, so it “breaks” the layout. Even if I use this markup :
With that CSS rule :
clear:both;
visibility:hidden;
padding:0;
margin:0;
line-height:0px;
}
The space used by that invisible line still occupies about 20px in height. Probably because margins are not collapsing on either sides (on top and below). The span occupies no space.
How is it useful ? When the sylesheet is disabled, your layout falls apart. Having lines separating these sections that are stacked one on top of the other is not particularly useful.
Update [April 17th] : I just read a description of this method. When using the ruler rubber band, the markup is : <hr class="clear" />. And it relies on that CSS rule : hr.clear {display: block; clear: both; visibility: hidden; height: 0; border-width: 0; margin: 0; padding: 0;}. I did not test this.
wonderful
Honestly, I was actually looking at this at the book store but i was not able to find it. hmm I don't know if it's already available here. i date asia||chnlove review
Most university, college and
Most university, college and high school students have benefited from cheap essay writing services having a coach at some point in their lives, either as a member of sports team, or as a participant in an individual sport.
good
I've tried this application and a few tips that you provide on this page. In my opinion, this application is quite right for my computer to have a faster connection.
ticketing companies
message
termite To create a such kind of article is really amazing,I daily read your blogs and give my announcement for that here this article is too great and so entertaining.
serwis laptopów
There is no need for downloading any unique programming on the PC to play this diversion on the web, getalternative-treatments each of the one ought to have is Internet association. health-alternative-therapies and searching alternatives of Google Chrome, Mozilla Firefox or Internet Explorer. get alternative treatments A different unique headline of Health connected is the discount go on wagers. health alternative therapies which is between 95-97 rate and reward. Most gigantic wins in club are recorded on amusements play on health.
great blog
american poker online spielen || chip runner online spielen You done certain good points there. I did a search on the subject and found nearly all persons will agree with your blog.
Great Post
Thanks for this post. I believe that HR is better than span always. I love this post it is very informative.
I recently found the
I recently found the application well dictated and then quickly logical. http://www.usajobstoday.us/ I must personally we appreciate the time you devote to create the application. I’m sure very gratified in addition to lose time waiting for your blog post.
The book CSS Mastery mentions the overflow method
Cool
Very cool. Drupal rules!
very interesting post.this
very interesting post.this is my first time visit here.i found so mmany interesting stuff in your blog especially its discussion..thanks for the post!
cliquez ici
Fatherly solve problems that
Fatherly solve problems that arise when we are doing the programming is not an easy thing to do. Therefore there is no harm if we renew our knowledge about it so that we can more easily overcome these problems. lakeway tx dentist
In developing software or a
In developing software or a blog we often find problems. But it is, can make our knowledge evolve to be better than ever. Therefore, if we find a problem in developing a blog, it's good if we are not easy to despair.
cheap homecoming dresses
fddf
novoline spiele online ||
novoline tipps
I simply stumbled upon your website and wanted to say that I have really enjoyed reading your blog post
A team that realizes that there is very little difference in talent 1-10 and that for them to succeed the starters should be playing very little more than the bench.
Popular package hip skirt is
Popular package hip skirt is to show their particular good & items .Leopard print elements are used ,will give girls charming flavor .There are Strapless equipped, small dew fragrant shoulder is feminine .sizzling hot für pc ||
slizzing hot
2 different Examples.
Hello,
One site I used
tag for clears instead of divs or spans. After diving head first into SEO, I thought it would be fun to use these instead of divs everywhere:#id-of-div h5 {
clear:both;
height:1px;
padding:0px;
margin:0px;
text-indent:-1000em;
width:670px;
}
Site Name
It was fun to test based on Sematic Web. What I learned that you could have multiple instances of
tags. I also used thetag but I found out from a SEO friend that thetag with the Site Title, should be the last thing the Search Bot reads.I also then experimented with the overflow: auto approach and found a solution. The only issue I found is that when you increased the Font size in IE 6 (ctrl + scroll wheel), the scrollbars appear. I used to benchmark my css-xhtml for IE6 but in the last 6 months, too bad. When you do a fresh install of Windows XP, during the updates, it prompts to install IE7.
Other than that I like the overflow:auto approach. Less divs, more semantic and works in the 4 main browsers.
I would post the code for the overflow approach but I am saving this for a nice float tutorial for my site.
I will post a link when ready.
chris
overflow:hidden
Try
overflow: hiddeninstead.liquid layout...
The reason for the {overflow:auto}, is trying to keep a liquid layout.
It seems to work for most browsers except IE6, which the scroll bars appear. I guess I should have explained what the goal of the final expectation was.
The {overflow:hidden}, did work very well though.
Have a good one.
chris
Application drupal is quite
Application drupal is quite widely used by computer users and from experience they have tried to respond as if they say positive about this application. In my opinion, this could be one of the apps that I can try as well. Breast Augmentation Houston
spammers suck
Well I think you have an IP address to block.
F%$king spammers suck.
Here is the whois:
inetnum: 89.149.241.0 - 89.149.244.255
netname: NETDIRECT-NET
descr: netdirekt e.K.
remarks: INFRA-AW
country: DE
admin-c: WW200-RIPE
tech-c: SR614-RIPE
status: ASSIGNED PA
mnt-by: NETDIRECT-MNT
mnt-lower: NETDIRECT-MNT
mnt-routes: NETDIRECT-MNT
source: RIPE # Filtered
lame
ps: sorry to hear about your relationship crap.
Travelling clears the mind
CSS EASY
My Idea
hr.clear {
clear:both;
visibility:hidden;
line-height:0px;
}
*{
padding:0;
margin:0;
}
Nice post dude ,... keep the
Nice post dude ,... keep the good work going by continue blogging new and entertaining posts. djarum black cigarettes
Unfortunately the
Unfortunately the application and this code can not be applied in internet explorer, when I use the browser. But I will download another browser like mozilla and opera, I hope this application can be applied in the browser. Randeep Grewal
Very useful article for me,
Very useful article for me, there is more information I have is very important. Thank you! diet sehat
I've tried a few tips that
I've tried a few tips that you share on this page. But why every time I enter the last code I always had a computer error? Is this error when I enter the code or my computer's problem?
I am not very proficient in
I am not very proficient in making a program for computers. In my opinion, too many codes that I did not understand before, so I often make mistakes when applying the codes on my computer.
Useful sharing
Excellent and decent post. I have found much informative, what I was exactly searching for. Thanks for such post and please keep it up.
A well great post made by
A well great post made by author, Thanks for it, It's really nice information and worth to read.
sarah and other name
I do not quite understand
I do not quite understand about this application. Honestly I have never not apply and very familiar with this application. But I will try to understand and enter the codes on this page.
Nice write-up
Generally I read more about publicly related topics and matters but never like this article. SO really I appreciate with you for your nice write-up. Great news Post. Always keeping up.
Himachal Packages | Himachal Tourism
Super article
Super article, I enjoyed reading your blog. Thank you.
To solve computer
To solve computer programming problems or things that make a computer do not work optimally, it takes some trial and research. In my opinion, it is quite challenging because we like you're in a situation to solve a puzzle.
There are many issues to be
There are many issues to be resolved because there are many people who had to cope with problems in his life so that life becomes normal again as before New Mexico contractors
I'm not really an expert in
I'm not really an expert in combining existing codes to program a computer. In my opinion, combines some of the code, enough to make me dizzy and a little bored.
This application seems to do
This application seems to do pretty well, I've tried this application and a few tips that you provide on this page. In my opinion, this application is quite right for my computer to have a faster connection. personal health insurance california
thank you
Hi! I just wanted to say thank you for sharing all this information with us. Keep up the great work. Bye.
Thanks for taking the time
Thanks for taking the time to discuss this, it is extremely helpful for me. I've read some excellent stuff here, great site.
A problem is will always
A problem is will always appear in one's life because there are many people who choose their own way to decide the issue that there is a consideration 服飾批發
really informative
Thanks for creating such a well written post which is really informative.
I've tried this application
I've tried this application and a few tips that you provide on this page. In my opinion, this application is quite right for my computer to have a faster connection.
There are many people who
There are many people who choose to solve the problem by finding the plot beforehand. You do have to make a correct and proper solutions to get the best. glock magazines
Each issue is bound to work
Each issue is bound to work out even if the solution is a difficult thing to be sought and obtained. However, we must continue to strive diligently to get it. Hackett pas cher
I also often experience when
I also often experience when they wanted to break the impasse program code for the web that I have and it made me stress. Therefore today I entrust it to someone more expert. injector
To apply these codes do not
To apply these codes do not seem quite difficult because you already gave a pretty clear guidelines on this page. In my opinion, these codes can make your blog look and performance become more attractive. New Jersey Sewer backup cleanup
informative post
Thank you for this informative post, I am glad I found this article via Google.
Apply the codes on this page
Apply the codes on this page does not seem difficult and can be done by self-taught. I am a layman in this field but I believe I can apply these codes because of the explanation is quite clear. apotik online
There are many new video is
There are many new video is uploaded to the internet to sites that provide this service every day. We were able to see there are many people who are very dependent on the video. nimodipino
Problem may be that there
Problem may be that there will indeed be one of the most difficult to solve if we really are in trouble the other and we're angry because there are many things that peeve. unlock blackberry
To break the codes on this
To break the codes on this page is not easy and requires thought. In my opinion, it could be one thing that is quite difficult if we do not have a basis in this field.
I am interested to develop a
I am interested to develop a website that I have and make it a commercial website. But to meet that goal, I have to do a lot of good marketing to build a website for it so often visited by internet users. Montana health insurance quote
To complete the existing
To complete the existing code in this application is quite complicated, so I read a variety of sources to be better in completing these codes and can immediately apply this application.
This article is really
This article is really useful and have been looking for some information on this topic. Great job and waiting for your next update.
Opus 6 Series
Extremely fantastic page. As i only just happened at your current blog site and even recommended expressing we need very loved studying your own site blogposts.
A way that could be used to
A way that could be used to spend a holiday is to follow an activity that can add to your knowledge, such as learning how to set up a humor to others. chin bar
great
novoline forum ||
novoline für pc
I desired to leave a little comment to support you and want you a good continuation.
Develop an application like
Develop an application like this is good enough to do. I personally was always trying to expand this blog so that I have can still be accepted by the visitors.
Drupal application is
Drupal application is already quite popular among internet users. I personally use this application to develop a blog that I have in order to display the maximum performance. LetteringOnTheCheap.com
I am a little confused to
I am a little confused to apply the method of the rubber bands that you mentioned on this page. In my opinion, this is very new to me so I need some references for this application can be successfully applied. atlantaworkerscompensation.com
Overflow of Elements
Had not thought about the idea of adding the class “clear-block” to the container element. The Rubber band' trick is an added bonus ;-) - very useful tips - thanks.
CSS - and adding clearing elements
Have tried to clear 'floats' using CSS. Found it helpful that you pointed out that rather than adding the clearing element directly to the markup I had to add it to the page dynamically. Had not figured that out! Also, helpful to know that it is necessary to indicate where the clearing element goes, and that this can be done by adding a class name. Thanks - really useful.
It is not easy to solve
It is not easy to solve problems that exist in a computer program. I personally can not afford to do that because I do not have enough knowledge and experience about it. used car lots louisville
I do not quite understand
I do not quite understand the language of the computer as well as software that is commonly used to develop a blog. I think the programming language is a language that is difficult to understand. bali yoga surf retreat
Problem
Has this problem re-appeard with more recent browser versions?
Problems that often occur in
Problems that often occur in the blog is quite challenging for the blog owner, but not the least the owners of blogs that do not care about that. I'm personally not too mastered how to combine existing codes properly. Dan Lozano
understanding on this subject
I have no point to raise in against of what you have said. You possess lots of understanding on this subject.
Perfectly written content
Perfectly written content, fantastic. I will come back later to read more of your articles, hope you keep up the good work.
A lot of the code that must
A lot of the code that must be understood in order to apply this application In my opinion, this is a pretty important thing to be learned when in reality it is not easy to do. infused olive oils
Anchorage Web Design
Solving a problem could be easy and could be difficult. It depends on the problem itself.
Anchorage Web Design
Post new comment