2-Column Float Around Image

This week I was presented with an interesting CSS challenge. An image in the middle of a page, with text flowing around both sides of it:

2-column-float

TL;DR? Click the image above to grab the code.

When I first looked at the design comp (not pictured), the two columns around the text jumped out at me right away as one of those well-I’m-sure-that-can-be-solved-but-I-have-no-idea-how-yet kind of problems. I set to work slicing up the comp and building the site, all the while letting this challenge ruminate in the back of my head. After a couple of hours, the build was done save for this element. And I still only had a few rough ideas of how to attack it, because there are a few details that make it extra challenging. The obvious problem of course is how to get that float to span both columns, but the extra tricky bit, if you look closely, is that the image has to float a set distance from the top of the column, rather than being anchored to the top of an element such as a paragraph.  The site is being built in Drupal, so I wanted to make sure that the client was able to edit the text of both columns without worrying about how it would affect the placement of the image.  Brainstorming with a co-worker, we found a few solutions that came close:

Close…

http://www.sampsonresume.com/labs/img-in-middle/

This one has the basic idea right, but it requires that the image be aligned to the top of the two columns. It set us down the right path, though.  Essentially, you’re showing half of the image in each column by floating a div of half the image width, and using the background-image and background-position properties to show the appropriate half of the image in each column.

Closer…

http://alistapart.com/article/crosscolumn

This one gets a little closer to the solution in that it allows you to arbitrarily place the image in the text without having to anchor to the top of an element. However, this article is ten years old[1], from before the widespread use of content management systems, and advocates simply sticking the image into the text of the paragraph wherever you’d like it. That’s fine, but you also have to match the placement of the other half of the image with a trial-and-error method in the other column.  As I said above, I want the client to be able to edit the text of both columns without worrying about the image placement.

Bingo!

The second solution was so close, but still not quite viable. So I did what I often do when presented with a difficult problem: I made my lunch and chewed on the problem while I chewed on a pastrami sandwich[2]. I came back to my computer and looked at it for just a second longer, and the solution became clear. What I needed was a prop of constant dimension to anchor to the top of each column, then push the two halves of the image down the appropriate distance. Using a combination of floating and clearing, I was able to put a one-pixel-wide prop before the image in each column, putting each image at the top of its respective column and therefore separating the image from the text content. Relevant bits of code are below, full working example can be found on JSBin.

The Markup:

<div class="col left">
  <h3>Left Column</h3>
  <div class="spacer"></div>
  <div class="img"></div>
  <p>Lorem ipsum...</p>
  <p>Lorem ipsum...</p>
</div>

<div class="col right">
  <h3>Right Column</h3>
  <div class="spacer"></div>
  <div class="img"></div>
  <p>Lorem ipsum...</p>
  <p>Lorem ipsum...</p>
</div>

The CSS:

* { 
  position: relative 
}

.col { 
  width: 365px; 
  padding: 0 15px; 
  float: left; 
}

div.spacer { 
  height: 100px; 
  width: 1px; 
}

div.img { 
  background: url(http://placehold.it/300x300) top left no-repeat; 
  height: 300px; 
  margin: 5px; 
  width: 150px; 
}

.col.right div.img { 
  background-position-x: right; 
}

.col.left .spacer { 
  float: right; 
}

.col.left .img { 
  float: right; 
  clear: right; 
  margin-right: -15px; 
}

.col.right .spacer { 
  float: left; 
}

.col.right .img { 
  float: left; 
  clear: left; 
  margin-left: -15px; 
}

Hopefully this post will help someone else facing the same problem, but who may not have the aid of a pastrami sandwich.


Notes

1) Kudos to ALA for promoting the type of content on their blog that is still mostly relevant after ten years. Taken out of a CMS context, this method is still a totally viable, semantically correct solution to the problem. Three cheers for web standards!
back

2) I’m a big fan of stepping back from a problem when I feel stuck. Another developer whose blog I enjoy agrees with me.
back

Posted in Nerd Stuff | Tagged , , |
Leave a comment

Hot Caraway Cider Toddy

Our friends Lee and Chelsea hosted Thanksgiving dinner this year as usual, and we were tasked with supplying a beverage to share. Last year I made a cider toddy from a recipe provided by a co-worker which was well received, and this year we had some caraway liqueur on hand which I have used to make some excellent whiskey cocktails.  I decided to riff on the recipe a bit to make use of the caraway, and the result was a fragrant[1], delicious hit. The recipe is easily scaled to whatever number of people you are planning to serve, so I give it to you here measured simply in parts. For large batches, heat on the stove until just before it simmers (boiling will boil off the alcohol) and then transfer to a crock pot to keep warm.  For making single servings, a microwave works just fine.

  • 4p Apple Cider – Any cider will do, but I prefer it on the less sweet side
  • 1p lemon juice – If you want to garnish each drink with a lemon peel, you’re welcome to squeeze a actual lemons.  For large batches, I say just use a store-bought bottle of lemon juice
  • 1p 50/50simple syrup – simmer equal parts water and sugar until clear, then let cool.
  • 2p 100 proof rye – Nothing fancy, but high proof will stand up to the sweetness of the cider. Rittenhouse 100 is great.
  • 1p caraway liqueur – This one is optional, but definitely adds a little something. I used Koval (because they’re down the street). If you forego the caraway, you might want to cut the lemon and simple syrup in half.
  • Whole Cloves – Obviously, the quantity will depend on how much you’re making. I made a big batch in a crock pot and put about a teaspoon of cloves into a tea bag while it heated.
  • Dash of Angostura Bitters (top each serving) – Angostura is of course the easiest of bitters to find. Feel free to riff here.


Notes

 1) Seriously fragrant. We tipped some over in the trunk of our hatchback on the way to dinner and the car still smells like boozy apple cider #noreallyofficer
back

Posted in Food and Drink, Make Stuff |
Leave a comment

Grapefruit on Rye

A while back we went to a whiskey tasting at Koval Distillery in our neighborhood, and came home with a bottle of their caraway liqueur.  I do love a whiskey cocktail and after Swedish Chefing[1] around in the kitchen a little bit, I came up with the following.  Serve in a rocks glass over one big-ass cube. (I’m sure there’s a name for those big-ass cubes, but I’m not that fancy)

  • 2p Bulleit Rye
  • 1p Caraway Liqueur
  • 1p Grapefruit juice
  • Dash of Angostura

1) Swedish Chefing is a common phenomenon in our kitchen.
back

Posted in Food and Drink, Make Stuff |
Leave a comment

Miscellany

It’s been a while since I’ve posted anything to the ol’ blog, so here are some photos from the last few weeks.

Posted in Chicago Adventures, Photos, Travel |
Leave a comment

Die Alpenhütten

So. We went hiking through the Austrian Alps for four days and three nights, sleeping each night in what are simply known as hütten (“huts”). They’re basically hostels up in the mountains that cater to hikers, climbers, mountaineers, and such, and allow you to go hiking for multiple days carrying little more than your clothing and some snacks for the trail. Jen has already detailed the trip in her blog far better than I could here, so I offer some photos and video. The alps really are like nothing I’ve ever seen. Huge, majestic, imposing, rugged. They seem to go on forever in every direction, including up. The photos and video really don’t do them justice, but it’s the best I can do without dragging you up to the tops of these mountains so you can see them for yourself.

And holy cow, here are some cows! The wind-chimey sound is because every cow had a bell.

A full panorama of the meadow

And here’s video from the peak of a mountain that we set out to walk around, but decided to climb instead. It’s 2,100m high (about 7,000 feet). It’s no fourteener, as the Coloradans say, but it certainly worked up an appetite for dinner.

And here’s dinner

image

Posted in Austrian Adventures, Honeymoon 2013, Photos, Travel | Tagged , , |
1 Comment

A Brief Interlude

image

We’re currently on the fast train between Munich and Berlin and as I’m watching southern Germany fly by in the morning light, I’m remembering back about four years ago. My open-ended trip across the US took me through morning-sun-drenched fields very similar to these–on a German motorcycle, no less. While I never quite put it into words at the time, I was struck by the thought, however cliché, that the sun rises on these fields every morning just like it does in Chicago. I was pretty caught up in my own problems in those months and seeking a little perspective, which I think I found over time. This feels like an extension of that moment. A simple reminder that whatever’s going on in my world, there are 7 billion other people in our world.

Posted in Off the cuff, Photos | Tagged |
Leave a comment

The Road North, or an Introduction to Italian Bureaucracy

So. It’s been a few days since the last post, and a lot has happened. I’ll try to get you all caught up efficiently, as that is the Austrian way (and not, as you shall soon see, the Italian way).

After our day at Cinque Terre, it was time to bid farewell to our Italian home and our warm, generous hosts, Chiara and Paolo. We were headed for Innsbruck, Austria with a one-night stop in Milan to see a college friend of Jen’s and meet her husband and new baby. One final Italian road trip got us up to Milan where we returned our rental car at the airport and took the local train into Stazzione Milano Centrale. We would be taking the train to Innsbruck the next morning, and for reasons that are not worth going into, we had to change our reservation to an earlier train. It was about 3pm and we figured we’d just breeze in, change our tickets, hop in a cab to Mattie’s place and be sipping wine by 4. Italians are known for their institutional efficiency, right?

No? Oh.

Crap.

We were unable to change our reservations at the automated machines, and we were directed down to the ticket office in the dungeon of the train station. (yeah, the basement. isn’t that what I said?) There we took a number. Actually, we took two numbers. There was a little machine that asked you what your problem was and issued you a number accordingly. I drew E285 and the Big Board (any Kubrick fans out there?) was showing that they were currently helping E250. Not too bad, because they were calling out a new number every five to ten seconds. After watching for a few minutes though, I discovered that they were calling a new E number about once every five to ten minutes. A’s and B’s, on the other hand, were clicking off like a coke-addled bingo caller. Ok, let’s play the naive tourist and pull a number for a different category. I pulled a B. B806 to be exact. I look up at the Big Board and they are currently helping B532. Not looking good for our heroes. Jen despairs of ever leaving the station, collapses on the floor, wailing, clutching her babushka around her shoulders, all of her worldly possessions in a single bag at her feet, and throws herself on the mercy of the uniformed man at the automated machine. I remain stoic in my best suit and hat amidst the wailing of hundreds of refugees, sure that if we can just make it past this official, a new and better life awaits us in the New World.

Ok, it wasn’t quite like that.

The man at the machine wasn’t a uniformed official, but an enterprising fellow who would push the buttons for you in the hopes that you might drop a Euro or two in his hand. Every couple of minutes an actual uniformed official would stroll by and the man would miraculously disappear, only to reappear as soon as the official would go. It was like watching a cartoon where Bugs Bunny would hide behind an impossibly narrow tree, or elude Elmer Fudd by following right behind him and matching his movements exactly. I considered pulling another lottery ticket, but Jen rightly pointed out that probably one of the reasons there were so many numbers ahead of us was jerks like me pulling multiple tickets. Fair point well made. I left Jen to keep our place in line and to let Mattie know that we were going to be later than anticipated while I headed out into the station to find:

A) Cash – because we had none on us

B) Food and/or caffiene – because our lack of cash would become a real problem if Jen had to bail me out of an Italian jail when my hunger caused me to turn Hulk in the Milano station.

C) Another way to change our tickets – because what did we have to lose?

I was unable to find A, and thus unable to acquire B*. However, I was able to find a travel agent that advertised that it could book TrenItalia** tickets. Our situation was slightly complicated by the fact that we were on a EuRail pass, which has all kinds of restrictions and only certain people can deal with, but as noted above, what did we have to lose? I mentally stocked up on as many Italian travel words and phrases as I could, armed myself with my most charmingest, disarmingest midwestern smile, and walked up to the counter.

I apologized in Italian and asked the man at the counter if he speaks English. “A bit”, he replied, although it turned out that his English is perfectly functional. English-speakers are truly spoiled by the fact that so many other people in the world speak our language. I asked him if he can book a reservation on a EuRail pass, and he said no. Well, it was worth a shot. I thanked him and headed back to see how Jen was faring at the ticket office. She was faring about as well as you can imagine. The numbers were inching closer to ours, but we were estimating another hour’s wait at least. I told her about the travel agent, and she said I should go back and see how much it would cost just to book the ticket, screw the EuRail pass. Our existing reservations were non-refundable so we were going to have to pay a bit for our new reservations anyway. We decided on a yea/nay monetary threshold for the cost of the tickets, and I went back, this time with our rail pass and our existing reservations.

I said hello again to my new friend the travel agent. He was my friend in that junior high, you’re-my-friend-but-maybe-I’m-not-yours sort of way. I hadn’t quite won him over, but again, had nothing to lose. I asked him what it would cost to book the tickets on the 9:05 to Innsbruck without the rail pass. It was well within the yea/nay threshold and so I asked him to please book it and showed him my existing reservation to make sure we were headed to the right station.

“You’re already booked to Innsbruck” he said, looking at my reservation.

“I know that, but I need an earlier train.”

“It will cost you more.”

Oh rub it in.

“I know that, but the line to book new reservations at the ticket office is at least another hour, and we have plans this evening.”

“Ok fine. Give me your EuRail pass, I can book you another reservation on it.”

Ah, excellent. Wait, what? You told me not ten minutes ago that you couldn’t do that, and to go to the ticket office. It was like Will Ferrell’s character in whichever Austin Powers movie that was, where you have to ask him everything three times, but then he’ll tell you anything you want to know.

He told me the price. I asked him if he accepted credit cards and he said yes, but would cost four euros more. Ok, no problem. I mean, at this point what’s another four euros?

Wait for it…

He needs those four euros in cash. Recall from items A, B, and C above that I had not yet been able to locate the cash machine. I falter momentarily, but regain that winningest, grinningest smile and ask him with amicable sheepishness (I’m winning him over, I can tell) if there is an ATM nearby. He looks at me for a second, then tells me to step two windows to the right where he can process those extra four euros by credit card.

Bene.

So I do, and he does. He hands me my train tickets, and I string together as many grazies, moltos, milles, and benes as possible in as many combinations as I can think of, and he finally smiles. I return to the ticket office to find my wife who is now resigned to her purgatorial existence. I burst through the doors, tickets clutched in one fist, both arms up and head tipped back in a victory cry. I muscle my way through the crowd, effortlessly scoop my wife into my arms and carry her out the door to the taxi stand, hundreds of beleaguered travelers erupting into cheers and applause behind us.

Ok, again, it was not quite like that. But I did silently strike that victory pose and it did turn a few heads. We headed out to the taxi stand and within twenty minutes we were eating cheese and drinking prosecco at Mattie’s place before heading out for a highlights-only walking tour and a fancy italian dinner at the Bulgari Hotel. Molto bene.

In the end, of course, it was not my winning smile and midwestern charm that won over the travel agent. My guess is that he just didn’t want to deal with me. I think he finally just assessed that the quickest way to get me out the door was to just book the stupid rail pass. But hey, whatever works, right?

* because, it turned out later, the map on the wall showing the location of the ATM was oriented 180 degrees from reality

** once you notice that the word TrenItalia so closely resembles the word Genitalia, you can’t unsee it. You will giggle a little at every train that goes by.

Posted in Italian Adventures, Travel |
4 Comments

Cinque Terre and High Performance Driving School – AKA the Autostrada Through the Italian Riviera

Yesterday, Jen and I went to Cinque Terre for the day. The three-plus hour drive to get there made it a little ambitious for a day trip, but well worth it in the end. Like every morning so far, we had grand plans for being up at 7 and on the road by 7:30. And like every morning so far, the previous night’s three-hour dinner that didn’t start until 9pm meant that we weren’t up until 8 (…ish). We were more or less ready to go by 9:30 or so, and then caused a minor kerfluffle when we came through the breakfast room intending to just grab some yogurt to eat on the road and met Paolo, our amazing and generous host, setting up the breakfast spread. He seemed genuinely concerned that we were not going to be eating a full breakfast, and we assured him (and assured him and assured him) that we would eat more on the road and that we would join him and the other guests for a full breakfast again tomorrow, but we had to get on the road early today (which was already not happening).

Yogurt and peaches in hand (and due espresso in stomach) we hopped in little Umberto Cinque and took off for the coast. At this point we’ve gotten pretty familiar with the roads around our village, and the freeways and toll roads out here are pretty unremarkable highway driving. An hour and a half into the drive (and due espresso later) we turned from the A6 onto the E80 and the fun began. This road runs from Genova along the coast of the Ligurian Sea and is a place where driving should be thought of as a grand adventure. Speed limits can be interpreted as a relative scale here. For instance, a speed limit of 130 k/h means drivers will be traveling somewhere between 130 and 180. A speed limit of 90 k/h means that drivers will be traveling somewhere between 90 and 180. See how that works? Quite clever. Little Umberto, while lacking the muscle to spring off the starting line, has the scrap and tenacity to (eventually) get up to 150 and handles like a champ at that speed. I’m also beginning to discover that a driver following closely on your tail here is not being aggressive, it’s just the way that people signal that they would like to go around you. It’s pretty practical, really. If I fail to notice someone who would like to pass me, he can politely reach out and tap me on the shoulder.

Following our lesson in performance driving we arrived in Monterossa, the westernmost of the Cinque Terre. While the Terre were once sleepy little fishing villages, they are now hyper-caffeinated tourist spots and by some miracle we got the last parking space in the lot closest to the town. As we got out of the car we discovered that no, it is not cooler by the sea. In fact, it was hot enough that we began to doubt our plan to hike all five villages. Monterossa is split into Old Town and New Town, and we made our way into New Town because that’s where the train station is. New Town contains the only sand beach in all of the five villages, so it’s a bit like a tiny Miami Beach. There are a thousand beach umbrellas packed as tightly as possible, and a boardwalk catering to all of the beachgoers, and all of humanity stacked on top of each other. Determined to retain Monterossa’s cultural identity, the chalkboards outside these traditional establishments would advertise such local specialties as the “drunk-ass bucket”. (These we renamed the “drunk ass-bucket” in honor of the champs who were drinking from them). In short, New Town Monterossa was kind of awful. We got a quick slice of pizza and a coke for lunch, and got our combination train ticket and hiking pass at the train station, where we learned that most of the trails were closed for maintenance today. Instead of hiking all five villages as we had planned, we would only be able to hike between village #2 (Vernazza) and village #3 (Corneglia). We’d be doing the rest of our village-hopping by train. Given the heat, that was A-OK with us.

We caught the first train to Vernazza which, while still overrun with tourists, was not so much of a spring-break-style bacchanalia as Monterossa had been. Vernazza is a spectacular terraced village cut into the hillside surrounded by vineyards that have to be harvested using a special trolley system to get the grapes up and down the hill. We tromped through the town and headed out onto the path to Corneglia, where we were sent on our way by a man playing an accordion on the hiking path. Awesome. Molto bene. It was about a 90 minute hike between the towns, and we drank in the spectacular coastal views as the path jutted out and back into the woods along the seaside. We were greeted just outside Corneglia by two more street musicians standing on the trail, this time an accordion and a saxophone. We were pretty wilted as we walked into town, and followed signs down to the marina, where we found a few dozen people swimming and sunning themselves on the rocky shore there. This was a little more our speed. With a modicum of modesty, we changed into our swim suits and hopped, squealing, into the chilly water. That perked us right up, let me tell you.

After that, we climbed back up the hill and found an afternoon gelato and a beer, took a quick jaunt on the train to Manola, the fourth village and scoped out the view, then boarded the train back to Monterossa for dinner. It turns out that Old Town Monterossa is way more charming and way less douchey than New Town Monterossa, and we had a delicious seafood dinner sitting at an outdoor table on a street about eight feet wide. We had to make it quick because we were getting on the road, so dinner was only two hours long. Another extended lesson in performance driving got us home, and we were in bed, road-weary and sun-baked, by about 12:30.

Next chapter: A Fancy Evening in Milano and the Trip to Innsbruck.

Posted in Italian Adventures, Travel | Tagged , , |
Leave a comment

Arrivederci, Italia! Grazie!

Leaving Italy today for Innsbruck. More travelogues to come, but here are a few pictures in the meantime.

The view from our agriturismo, Cascina Sant’Eufemia

image

The view of the view

image

Beer o’clock in Torino

image

In Italy, donuts are apparently known as “Simpsons”

image

Posted in Italian Adventures, Photos, Travel | Tagged , , , , , |
Leave a comment

On the road to Torino

image

On the road with Umberetto Cinque.

Posted in Italian Adventures, Photos, Travel | Tagged , , |
Leave a comment