A CSS solution to two equal-height columns in HTML
It seems to be a very tricky problem to make two columns with equal height in HTML using CSS. There are many articles on how to do it. Maybe the most reliable way is to use Javascript to force it at the browser side since all CSS solutions look like hacks. I also found a possible solution using CSS.
The problem is like this. It is very common to create a two-column layout in CSS. Most books only cover how to make it using float and margin. It is enough if the columns have no background color or border. However, if you need to put a background color or border for the shorter column, you may find that its height is not as the same as the longer one as shown below. By default, a block’s height is determined by its content.
You can see the effect here. The effect is different when the DOCTYPE is XHTML or HTML. The main CSS and HTML parts are like this.
<style type="text/css">
#container {
width: 500px;
}
#left_col {
float: left;
background-color: #573333;
width: 150px;
}
#right_col {
width: 350px;
background-color: #DDD;
margin-left: 150px;
}
</style>
<body>
<div id="container">
<div id="left_col">
Left Column ...
</div>
<div id="right_col">
Right Column ...
</div>
</div>
</body>
The solution I found is to add “position: relative;” to the container and add “position: absolute; height: 100%;” to left_col. Every single change counts. You must put all of them. Also, I removed “float:left” from left_col. But it is safe to keep it there. The new style is like this.
<style type="text/css">
#container {
width: 500px;
position: relative;
}
#left_col {
background-color: #573333;
width: 150px;
position: absolute;
height: 100%;
}
#right_col {
width: 350px;
background-color: #DDD;
margin-left: 150px;
}
</style>
Then it will render the layout as follows. You can see the effect here.
Why? I don’t know.I found this trick from the CSS of Yahoo Search. Yahoo search results are in 2-column layout. I found this CSS trick is at least one of many tricks they use to force the left column to be the equal height of the right column. However, I got a theory (actually a feeling) for it. I guess, by declaring left column as position:absolute, CSS rendering somehow delays the time point to determine its final layout until other components in the container are rendered. I put Javascript at a few breakpoints in HTML to print its height. I found it is 0 after its content is rendered. Then it increases while the right column is rendered. So does the container’s height.
Is this a hack? I found it works on all browsers and all operating systems I can find.
There is one problem with this solution. It only works when the left column is shorter than the right one. The left column will be as equal high as the right column anyway even if the right column is shorter.
Install WinRAR on Fedora
Simply put, to install WinRar on Fedora:
rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm yum install unrar
The first command adds rpmfusion into your yum repository. Then, the yum command installs unrar from rpmfusion. Now you can extract rar files by ‘unrar e filename’. During the installation of unrar, yum may prompt you if it is OK to import GPG key from RPM Fusion nonfree repository? Type y to add it.
WinRAR is provided by RARLAB. Its download page points to rpm.livna.org for Linux version unrar. However, livna has been merged to rpmfusion. Thus, you should add rpmfusion into your yum repository instead. To do that, either follow the section “command line setup using rpm” on its config page or only add the nonfree repository (WinRAR is not open sourced) as I did above.
Install Ruby On Rails and Django on Fedora
Some notes about installing ruby on rails and django on fedora 11.
To install ROR on Fedora:
yum install mysql yum install mysql-devel yum install ruby yum install rubygems gem install rails gem install mysql
Later, I found the gem installed by yum is 1.3.1, which is lower than required by rake. So I downloaded rubygems-1.3.5.tgz from http://rubyforge.org/frs/?group_id=126, and installed it by
> ruby setup.rb
To test the installation of mysql, write a ruby script with
require "mysql"
But I got this error,
mysqltestst.rb:1:in `require': no such file to load -- mysql (LoadError)
To fix it, add environment variable RUBYOPT=rubygems
Another way is as follows
require "rubygems" require "mysql"
To install Django on Fedora:
yum install Django yum install MySQL-python.i586
Weird Boot Error: virbr0 starting userspace STP failed
I suddenly could not boot my Linux box (Fedora 11) today. It showed some error messages as follows,
virbr0: starting userspace STP failed, starting kernel STP ADDRCONF(NETDEV_UP): eth0: link is not ready e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None 0000:00:19.0: eth0: 10/100 speed: disabling TSO ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
In the beginning, I thought it is related to network or libvirtd. But I did not solve the problem by turning off libvirtd. I did not change anything in my last boot. But I updated Fedora packages using Software Update. However, I did not pay attention what I updated. By searching on web, I found some people talked about this issue after upgrading video drivers. I felt it may be the same reason.
My video card is Nvidia. I used nvidia linux driver (NVIDIA-Linux-x86-190.42-pkg1.run) downloaded from nvidia web site. To give it a try, I decided to reinstall it. So I boot at runlevel 3, and run the driver installer NVIDIA-Linux-x86-190.42-pkg1.run again in text mode. It rebuilt the driver and reset xorg.conf. Then, the problem was fixed.
After that, I found that there are actually a lot of errors in /var/log/Xorg.?.log such as
NVIDIA: Failed to load the NVIDIA kernel module. Please check your system's kernel log for additional error messages.
Also, /var/log/messages log has error message as follows.
WARNING: GdmLocalDisplayFactory: maximum number of X display failures reached: check X server log for errors init:prefdm main process terminated with status 1
So this weird boot error is really caused by video driver. The errors related to virbr0 were just coincident errors that showed up after X failed to start. I checked my logs. Such errors have been there for every boot. I just did not see them. Now I turn off libvirtd service.
FYI, to boot into runlevel 3 in this hanging case. Select the linux image entry to boot in GRUB, press ‘e’. In next screen, move to the kernel line, press ‘e’. In my case, it ends up with ‘rhgb quiet’, which is redhat graphic boot. Delete ‘rhgb, quite’, replace it with ‘3′. Then press ‘b’. It will boot to runlevel 3 without starting those daemons or X window. Just log in as root and reinstall the video driver. If runlevel 3 does not work, try single user mode, i.e. replace ‘rhgb quite’ with ’single’.
Ruby MySQL adapter on Windows
It is very easy to install Ruby MySQL adapter using gem on Windows.
gem install mysql
But I found Ruby MySQL adapter does not work with MySQL 5.1 on my Windows box. When Ruby executed SQLs or Rails server got requests, I got some errors like this
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/abstract_adapter.rb:39: [BUG] Segmentation fault ruby 1.8.6 (2009-08-04) [i386-mingw32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
It seems the reason is that this version of mysql gem does not work with MySQL 5.1 lib. I saw some suggestions on Web to downgrade MySQL to 5.0 to solve the problem. However, I don’t want to downgrade MySQL. It turns out the solution is very simple. Download MySQL 5.0 noinstall version mysql-noinstall-5.0.89-win32.zip from http://dev.mysql.com/downloads/mysql/5.0.html. Extract libmysql.dll and copy it to C:\Ruby\bin. Then, the problem is solved. I am still running MySQL 5.1. But Ruby uses this MySQL 5.0 version dll.
My environment: Ruby 1.8.6. Gem 1.3.5. MySQL gem version 2.8.1. Rails version is 2.3.5. Windows XP and MySQL 5.1.

