<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc=" http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>briancarper.net (λ) (Tag: CSS)</title><link>http://briancarper.net/tag/177/css</link><description>Some guy's blog about programming and Linux and cows.</description><item><title>Split page vertically in CSS (minus pixels)</title><link>http://briancarper.net/blog/589/split-page-vertically-in-css-minus-pixels</link><guid>http://briancarper.net/blog/589/split-page-vertically-in-css-minus-pixels</guid><pubDate>Mon, 23 Apr 2012 21:43:06 -0700</pubDate><description>&lt;p&gt;I was designing an online database application recently.  The layout I wanted was, I thought, fairly simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;N pixel header at the top&lt;/li&gt;
&lt;li&gt;The rest of the page split vertically into two panes&lt;/li&gt;
&lt;li&gt;Each pane should scroll independently&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Super easy to do in CSS, right?  Of course not!  You can't do this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;brush: css&quot;&gt;#header {  height: 50px; }

#panels {  height: 100% - 50px; }

#top, #bottom { overflow: auto; }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is because (of course) you can't do simple arithmetic in CSS. &lt;/p&gt;

&lt;p&gt;I can't think of a reason why it's not supported.  My browser knows the height of the window at any given point in time.  The browser can surely subtract two numbers.  If someone knows of a solid reason why we can't do this in CSS, please clue me in.&lt;/p&gt;

&lt;p&gt;I can think of many reasons why I would want to do it though.  The above use case is just one of them.&lt;/p&gt;

&lt;p&gt;I really dislike resorting to this (which does work, as seen &lt;a href=&quot;/random/layout-good.html&quot;&gt;here&lt;/a&gt;):&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;brush: css&quot;&gt;#header {  height: 50px; }

#panels {
    position: absolute;
    top: 50px;
    left: 0px;
    right: 0px;
    bottom: 0px;
}

#top, #bottom { overflow: auto; }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Whenever I start using absolute positioning, I know something went off the rails somewhere.&lt;/p&gt;

&lt;p&gt;The worst part isn't that CSS doesn't support this, it's that even if CSS did suddenly support it, I couldn't use it until sometime in 2023 when all the major browsers implemented it and everyone using the old browsers switched or died of old age.&lt;/p&gt;</description></item><item><title>gaka 0.2.0</title><link>http://briancarper.net/blog/562/gaka-020</link><guid>http://briancarper.net/blog/562/gaka-020</guid><pubDate>Thu, 29 Jul 2010 13:59:22 -0700</pubDate><description>&lt;p&gt;Per &lt;a href=&quot;http://briancarper.net/blog/543/introducing-gaka&quot;&gt;many commenters' suggestions&lt;/a&gt; and thanks to code from &lt;a href=&quot;http://github.com/purcell/&quot;&gt;Steve Purcell&lt;/a&gt;, you can now use maps for CSS attributes in &lt;a href=&quot;http://github.com/briancarper/gaka&quot;&gt;gaka&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;brush: clojure&quot;&gt;user&amp;gt; (println (gaka/css [:a {:color :red}]))
a {
  color: red;}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This looks more like vanilla CSS thanks to the curlies, which is nice.   You just have to keep in mind that your key/value pairs could end up being printed in random order, and order is significant&lt;sup id=&quot;fnref:css&quot;&gt;&lt;a href=&quot;#fn:css&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; in CSS.&lt;/p&gt;

&lt;p&gt;It just so happens that maps are implemented in Clojure right now such that if they only have a few entries (16 key/value pairs), the order will be preserved, because you get a &lt;code&gt;PersistentArrayMap&lt;/code&gt; instead of a &lt;code&gt;PersistentHashMap&lt;/code&gt;.  But it's &lt;em&gt;highly dangerous&lt;/em&gt; to rely on such a thing.  It could change at any time in the future.&lt;/p&gt;

&lt;p&gt;In any case, you can also mix and match maps, lists and &quot;flat&quot; keyvals.  They'll all be flattened  That can help preserve attribute order in those cases where you need to.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;brush: clojure&quot;&gt;user&amp;gt; (println (gaka/css [:a :color &quot;red&quot; {:padding 0} (list :margin 0)]))
a {
  color: red;
  padding: 0;
  margin: 0;}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I've also enhanced &quot;mixins&quot; a bit further.  You can now mixin entire tags as well as attributes.  Or a combination of both.  Say you want a mixin that means &quot;&lt;em&gt;Make my element have no padding, and make links within the element be red&lt;/em&gt;&quot;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;brush: clojure&quot;&gt;user&amp;gt; (println (gaka/css [:div.foo mixin :margin 0]
                         [:div.bar mixin]))
div.foo {
  padding: 0;
  margin: 0;}

  div.foo a {
    color: red;}

div.bar {
  padding: 0;}

  div.bar a {
    color: red;}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can get gaka from &lt;a href=&quot;http://github.com/briancarper/gaka&quot;&gt;github&lt;/a&gt; or &lt;a href=&quot;http://clojars.org/gaka&quot;&gt;Clojars&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;footnotes&quot;&gt;&lt;ol&gt;&lt;li id=&quot;fn:css&quot;&gt;&lt;p&gt;Order is only significant in cases where you're doing things like &lt;code&gt;padding: 0; padding-left: 1px&lt;/code&gt;.  This is arguably bad CSS style, but it's valid, and it's also possible you'll have this kind of thing if you're generating CSS procedurally.  But most of the time, order is not significant.  e.g. it doesn't matter if you set text color first and background color second, or vice versa.  So maybe this isn't so much of a problem in practice. &lt;a rev=&quot;footnote&quot; href=&quot;#fnref:css&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</description></item><item><title>Introducing Gaka</title><link>http://briancarper.net/blog/543/introducing-gaka</link><guid>http://briancarper.net/blog/543/introducing-gaka</guid><pubDate>Mon, 28 Jun 2010 17:59:26 -0700</pubDate><description>&lt;p&gt;The CSS for &lt;a href=&quot;http://github.com/briancarper/cow-blog&quot;&gt;my blog&lt;/a&gt; is now being generated via &lt;a href=&quot;http://github.com/briancarper/gaka&quot;&gt;gaka&lt;/a&gt;, a CSS-generating library I wrote this afternoon.  It's extremely simple, but it got the job done for me.  I turned around 600 lines of CSS into around 250 lines of Clojure without much effort.  It looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;user&amp;gt; (require '(gaka [core :as gaka]))
nil
user&amp;gt; (def rules [:div#foo
                  :margin &quot;0px&quot;
                  [:span.bar
                   :color &quot;black&quot;
                   :font-weight &quot;bold&quot;
                   [:a:hover
                    :text-decoration &quot;none&quot;]]])
#'user/rules
user&amp;gt; (println (gaka/css rules))
div#foo {
  margin: 0px;}

  div#foo span.bar {
    color: black;
    font-weight: bold;}

    div#foo span.bar a:hover {
      text-decoration: none;}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Gaka is partly inspired by &lt;a href=&quot;http://sass-lang.com/&quot;&gt;Sass&lt;/a&gt;, which I found very pleasant to work with recently.  And it's partly inspired by &lt;a href=&quot;http://github.com/weavejester/hiccup&quot;&gt;Hiccup&lt;/a&gt;, which is a delicious way to generate HTML in Clojure.  &lt;/p&gt;

&lt;p&gt;There's more info and more examples on &lt;a href=&quot;http://github.com/briancarper/gaka&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Line wrapping pre tags</title><link>http://briancarper.net/blog/line-wrapping-pre-tags</link><guid>http://briancarper.net/blog/line-wrapping-pre-tags</guid><pubDate>Sun, 10 Feb 2008 17:38:50 -0800</pubDate><description>&lt;p&gt;For a long time my blog layout has been a bit screwy; it had a hard minimum width for the central column of the layout, which caused an annoying need for horizontal scrolling after you make your browser window small enough horizontally.  Nothing in my CSS was causing this as far as I could tell.&lt;/p&gt;

&lt;p&gt;Turns out it was the &lt;code&gt;PRE&lt;/code&gt; tags that I put my code snippits in.  They weren't line-wrapping.  I found &lt;a href=&quot;http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/&quot;&gt;a page&lt;/a&gt; with some CSS to make PRE tags line-wrap and now my site looks better in narrow windows in Firefox, Opera and Konqueror.&lt;/p&gt;

&lt;p&gt;Turns out it doesn't work in IE7.  Of course.  But if you're using IE7, my site looking odd is the least of your problems.  Also I didn't test it in IE6, and I don't really care what it looks like in IE6.  IE6 is already dead and buried, in my eyes.&lt;/p&gt;</description></item><item><title>New layout done</title><link>http://briancarper.net/blog/new-layout-done</link><guid>http://briancarper.net/blog/new-layout-done</guid><pubDate>Sat, 17 Mar 2007 12:37:19 -0700</pubDate><description>&lt;p&gt;I was searching for sites on web design, and I came across a novel concept: The primary goal of a site's design should be to be easy to read.  Who would've thought?  This new layout is the first layout I ever made with that focus in mind.  Usually my design goal is &quot;Show off&quot;, or &quot;Try some new HTML/CSS tricks&quot;, or... well, that's about it.  &lt;/p&gt;

&lt;p&gt;I despise web design, as a rule.  But I always find typography to be somehow fascinating.  I remember over a decade ago sitting in Windows 3.1 on my first computer trying to make my own font files.  And of course I begged my parents for a calligraphy pen, which I had lots of fun with.  Serif vs. non-serif, letter height proportions, width proportions, spacing, those kinds of things, and their relation to easiness to read.  I thought this &lt;a href=&quot;http://www.alistapart.com/articles/whitespace/&quot;&gt;article about whitespace&lt;/a&gt; was really interesting, especially the part saying:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Less whitespace = cheap; more whitespace = luxury.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My old layout was very cluttered and light on the whitespace, and it DID look cheap.  I wasn't going for &quot;cheap&quot; when I made it, more like &quot;informal&quot; or &quot;fun&quot;.  But same idea.  This time I wanted to go for something less cheap, so I have lots more whitespace.&lt;/p&gt;

&lt;p&gt;Regardless, I am not at all skilled at web design, or typography, or anything of the sort.  But it is fun to dabble sometimes.&lt;/p&gt;</description></item><item><title>Even more cow</title><link>http://briancarper.net/blog/even-more-cow</link><guid>http://briancarper.net/blog/even-more-cow</guid><pubDate>Sun, 03 Dec 2006 22:26:35 -0800</pubDate><description>&lt;p&gt;I updated my layout to be even more cow-like.  My girlfriend made me a cow-themed top banner which I think looks good enough to eat.  I often wish I had any kind of graphic design skill, but I don't.  Not nearly as good as her, anyways.&lt;/p&gt;

&lt;p&gt;It's always so hard to find a good balance between leaving something readable, and making it look good and catch the eye and stand out in some way.  As much of a geek as I am, even I will probably pass by a plain-looking site unless I know beforehand that there's something on it that's worth reading.  Putting some effort into making your site look nice shows that you actually give a crap about the site, I think.  And the more you give a crap about the site, the more likely there is going to be something worth reading on it.&lt;/p&gt;

&lt;p&gt;Wordpress impressed me today.  I remember a long time ago making a calendar (to list your post archives) was extremely painful.  Now you can do it with a single &lt;code&gt;get_calendar&lt;/code&gt; call, and it looks fine and works fine.  I like relying on Wordpress for this kind of crap because chances are they already worked out what works in IE and what doesn't.&lt;/p&gt;

&lt;p&gt;Which brings me to my next point.... dear God, IE sucks.  If you're looking at this site in IE right now, and you're using a screen resolution 1024x768 or lower, you'll notice that my site is so wide that it forces a horizontal scrollbar.  This isn't so in Firefox.  In IE though, the existence of &lt;code&gt;pre&lt;/code&gt; tags apparently causes everything to stretch, even when I indicate &lt;code&gt;overflow:auto&lt;/code&gt; or &lt;code&gt;overflow:scroll&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And IE interprets &lt;code&gt;border: 1px transparent solid&lt;/code&gt; to mean &lt;code&gt;border: 1px BLINDING_WHITE solid&lt;/code&gt;.  It makes you cry, after a certain point.  Also my top header image is a transparent png which looks like garbage in IE, but I'm not fixing it.  &lt;/p&gt;

&lt;p&gt;Whenever IE drives me into a murderous rage, I just pull up my site stats and suddenly everything seems right with the world:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/random/browser_stats.png&quot; alt=&quot;Browser stats&quot; /&gt;&lt;/p&gt;</description></item><item><title>Layout update</title><link>http://briancarper.net/blog/layout-update</link><guid>http://briancarper.net/blog/layout-update</guid><pubDate>Wed, 25 Oct 2006 23:54:18 -0700</pubDate><description>&lt;p&gt;I've made some fairly significant changes to my blog's layout.  Most importantly, I've added a cow's bum.  I've said it before and I'll say it again: You simply can't go wrong with cow-based web site layouts.  I still have a bit more work to do (for another day) but I think it turned out OK.  &lt;/p&gt;

&lt;p&gt;This went smoothly largely thanks to Debian.  I spent an hour or so today setting up my Debian box as a mirror of my blog.  It really was simple and easy and most of all extremely fast.  I had some weird problems though; for example apparently bzip2 isn't installed on Debian by default (???).  That's a first.  But hey, it installs in 5 seconds, so it's not a huge problem.  Mmmm, non-source-based distro.  Samba also was extremely easy to set up.  I noticed that Debian's samba comes with a rather more sane default config file than Gentoo's, which is something I think I've noticed about Debian in general.&lt;/p&gt;</description></item><item><title>Firefox theming sucks</title><link>http://briancarper.net/blog/firefox-theming-sucks</link><guid>http://briancarper.net/blog/firefox-theming-sucks</guid><pubDate>Thu, 07 Sep 2006 16:23:47 -0700</pubDate><description>&lt;p&gt;Firefox makes me sad.  There are many reasons, but if I had to pick one, I'd say theming.  Writing a Firefox theme is so ridiculously hard as to be pretty much not worth the effort.  I wrote the &lt;a href=&quot;https://addons.mozilla.org/firefox/187/&quot;&gt;Lila theme&lt;/a&gt; for Firefox a couple years ago.  I kept up with it for a few Firefox versions, but there's just no way any sane person would want to continue doing so.&lt;/p&gt;

&lt;p&gt;The theme itself is packaged as a jar file, for reasons that are beyond me.  Inside this file are XML files which you get to hand-edit.  Now, don't confuse Firefox's UUID with your theme's UUID (which you must generate manually in some way).  Remember, em:targetApplication.Description.em:id is where YOUR UUID goes!&lt;/p&gt;

&lt;p&gt;The whole layout is controlled by CSS.  Not just CSS, but CSS with Firefox-specific crap mixed in.  These CSS files are scattered randomly through a bunch of directories with helpful names like &quot;browser&quot; and &quot;global&quot; and &quot;communicator&quot;.  I assume some of these are leftover trash from Netscape, but I have no idea.  There are many times you'll find two directories with the same name, and you have little idea which of them you should be using.  global/icons or browser/icons?  Beats me.  Some folders contain image files that look like they were designed for Windows 3.1, which again I assume is some kind of legacy remnant of Netscape.  &lt;/p&gt;

&lt;p&gt;If you want to change the look of a single component of the display, you're likely required to wade through 4 or 5 levels of cascading CSS files scattered in multiple directories.  The partial solution to this is apparently to stick !important on everything, to override everything that came before it.  However this too loses its usefulness after the 4th layer of !important's overriding !important's.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ grep -r '!important' `find lila -iname '*.css'` | wc -l
666
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I didn't make that number up.  How interesting.  &lt;/p&gt;

&lt;p&gt;At the time I wrote my theme, there was absolutely no documentation (that I could find) on how to do anything.  Basically you were expected to wade through a couple hundred threads at &lt;a href=&quot;http://forums.mozillazine.org/viewforum.php?f=18&quot;&gt;MozillaZine&lt;/a&gt; or something.  In practice what everyone did was grab someone else's theme as use it as a default, because otherwise you have no chance.  (Clearly someone, somewhere came up with the FIRST theme, from which all others are derived.  My theory is that this original theme was introduced into human society by extra-terrestrials or some kind of god-figure.)&lt;/p&gt;

&lt;p&gt;The hoops you have to go through to test a theme while working on it is ridiculous.  The normal theme install procedure for Firefox was designed by someone with a severe masochistic streak.  Where is the Lila theme installed on your computer?  If you guessed &lt;code&gt;~/.mozilla/firefox/01yf2p25.default/extensions/{9957f6c1-021d-4cbf-9462-26a0c1921fe4}/chrome&lt;/code&gt;, you're right!  But that's just the location of your theme's jar file.  If you want Firefox to read it in non-jar format, it's possible, but the method of setting it up can only be called black magic.  But without doing this, seeing the result of making any change in your theme requires 5 minutes of fumbling.  &lt;/p&gt;

&lt;p&gt;Is there a difference between themes for Linux, OS X, and Windows?  Clearly so, because those things are specified on the specs for each theme on the Firefox site.  What exactly those changes are, or how to resolve them, I would not want to begin to guess.&lt;/p&gt;

&lt;p&gt;The best thing is that every Firefox release completely breaks old themes.  Even today at MozillaZine we have a &lt;a href=&quot;http://forums.mozillazine.org/viewtopic.php?t=387650&quot;&gt;16 page thread&lt;/a&gt; about changes from 1.5 to 2.0.  And there's already an &lt;a href=&quot;http://forums.mozillazine.org/viewtopic.php?t=346022&quot;&gt;8 page thread&lt;/a&gt; about changes from 1.5 to 3.0 (God help us all).&lt;/p&gt;

&lt;p&gt;Someone apparently updated my Lila theme for version 1.5 at the &lt;a href=&quot;http://lila-theme.uni.cc/index.php?page=downloads&quot;&gt;official Lila page&lt;/a&gt;.  I installed it, and big surprise, it's broken.  The RSS/secure connection icons in the toolbar are totally trashed in the layout.  Menus have random highlighting problems.  Etc.  And here comes Firefox 2.0!  Time to rewrite it again!  Big chance this theme won't even install in version 2.0, let alone look correct.  Nothing at all against whoever updated this theme; I tried to update my old one for version 1.5 myself and I just gave up.  Not worth it.&lt;/p&gt;</description></item><item><title>*sepuku*</title><link>http://briancarper.net/blog/sepuku</link><guid>http://briancarper.net/blog/sepuku</guid><pubDate>Sun, 25 Jun 2006 12:33:27 -0700</pubDate><description>&lt;p&gt;I may have had the stylesheet for this site linking from localhost for the past couple days.  And I couldn't tell because I hadn't looked at it from anywhere but home until now.  Oops.&lt;/p&gt;</description></item><item><title>A sad, sad day</title><link>http://briancarper.net/blog/a-sad-sad-day</link><guid>http://briancarper.net/blog/a-sad-sad-day</guid><pubDate>Fri, 23 Jun 2006 20:37:21 -0700</pubDate><description>&lt;p&gt;I spent the time to get this site to work in &lt;a href=&quot;http://www.google.com/search?q=internet+explorer+sucks&quot;&gt;Internet Explorer&lt;/a&gt;.  It still works in Firefox and Opera of course, and that's the extent to which I'm going to bother testing. (Well, OK, here's a screenshot of my site in &lt;a href=&quot;/random/lynx.png&quot;&gt;lynx&lt;/a&gt;.  Still looks great to me!)  I also added some color, because all the grey and the lack of contrast was causing permanent damage to my nervous system.  It's pretty bad when bright orange makes your site look BETTER.&lt;/p&gt;

&lt;p&gt;I ended up going to a table-based layout.  I know it's The Wrong Way&amp;#153; to do things.  But in my opinion, CSS can't handle column-based layouts worth crap.  I learned today that there are actually tags in CSS to support &lt;a href=&quot;http://www.w3.org/1999/06/WD-css3-multicol-19990623&quot;&gt;a multi-column layout&lt;/a&gt;.  But I know IE doesn't support them, if any other browser does.  Who knows.    &lt;/p&gt;

&lt;p&gt;Getting three columns, one of which is resizable, and all of which are the SAME HEIGHT, without using tables, is like trying to program HTML with 9 broken fingers while a rabid monkey attacks your face.  Cheap hacks with &lt;code&gt;float&lt;/code&gt;s or &lt;code&gt;position:absolute&lt;/code&gt; is not my idea of an elegant approach to web design, when a simple full-site wrapper table does it exactly right.  Use a table to split the site up into sectors of specific size and orientation and alignment, and then CSS your brians out, that's what I say.&lt;/p&gt;</description></item></channel></rss>

