A css layout challlenge - any help would be greatly appreciated

Hello all,

I’m really clueless about this one.

Should work on IE7, IE8, and good browsers;

Any advice about how to make this happen?

I don’t need any code related to it.

And equal heights columns are NOT a mandatory request.
If is less painful to use min-height or even height, it’s ok.

A)Should we absolute position the text on a container with ALL three columns as a single image as background?
B)Should we place three divs and, on each have the rounded shape as a background?
C)Should we have three container column divs and, inside each, two more divs? One for the rounded stuff, and the other for the column?
D)Should we absolute position the rounded shape, to the yellow column, and give it a negative top value?

Any other E) perhaps?

Please advice. I’ve tried a lot already, but I’m really far from a great result, and the only thing I get its hack after hack…

If anyone could be kind enough to spare a few moments dealing with this, I would love to.

Thanks in advance.

Just the columns:

                    <div id="container1">
                        <div class="main-column">
                            <h2>Hello tittle 1</h2>
                            <div class="text-column">
                                <p>I'm on column 1 and I like it</p>
                                <p>I'm on column 1 as well</p>
                            </div>
                        </div>
                        <div class="main-column">
                            <h2>Hello tittle 2</h2>
                            <div class="text-column">
                                <p>I'm on column 2 and I like it</p>
                                <p>I'm on column 2 as well</p>
                            </div>
                        </div>
                        <div class="main-column">
                            <h2>Hello tittle 3</h2>
                            <div class="text-column">
                                <p>I'm on column 3 and I like it</p>
                                <p>I'm on column 3 as well</p>
                            </div>
                        </div>
                    </div>
#container1 {
    background-color: red;
    text-align: center;
}

.main-column {
    display: inline-block;
}

.main-column h2 {
    width: 300px;
    height: 235px;
    padding-top: 110px;
    position: relative;
    background: url('http://s24.postimg.org/ossqwb7hh/carica_Kairos.png') no-repeat top center;
}

.text-column {
    width: 220px;
    height: 300px;
    background-color: yellow;
    margin: -223px auto 0 auto;
    padding-top: 220px;
}

.text-column p {
    padding: 0 50px;
}

I can’t get the top image to display on ie8 and older.

:frowning:

I ran some quick checks and cannot make the image NOT show up in IE8. The column gets funky in Quirks mode, but the image is still there. I don’t see the problem.

#slide2 .table {
    overflow: hidden;
    margin: 0 auto;
}

#slide2 .column {
    width:320px;
    background: url('http://s24.postimg.org/sc8ukv7hh/background_Acerca.png') no-repeat bottom center;
    display:inline-block;
    overflow: hidden;
    margin-bottom: -6px; /* Hack 1 :( */
}

#slide2 .slide-head {
    text-transform: uppercase;
    font-size: 1.25em;
    width: 178px;
    margin-left: auto;
    margin-right: auto;
    padding-top: 80px;
    margin-bottom: 130px;
}

#slide2 .slide-body {
    font-size: 1em;
    width: 178px;
    margin-left: auto;
    margin-right: auto;
}

#slide2 .slide-head.left {
    margin-bottom: 120px;
}

#slide2 .slide-body.left {
    margin-bottom: 60px;
}

#slide2 .slide-body.middle {
    margin-bottom: 70px;
}


#slide2 .slide-head.right {
    margin-bottom: 100px;
}

#slide2 .slide-body.right {
    margin-bottom: 30px;
}
<div class="table">
 <div class="column">
  <div>
   <h3 class="slide-head left">asdasd adsada adasd adasda asdas sdasdasdas asdasd</h3>
   <p class="slide-body left">adasd sada asda asdas asdas asdsadasdsa asdasdas asdsad asdsa asdsad.</p>
  </div>
 </div>
 <div class="column">
  <div>
   <h3 class="slide-head middle">adasd asdsad asdsa sadasdas asdasd asd</h3>
    <p class="slide-body middle">asdasd asdas adsad asdasdasd asdasdas adasdsad asdasd adsad asdasdsa sada</p>
  </div>
 </div>
 <div class="column">
  <div>
  <h3 class="slide-head right">adsads adasd adasd asdasd asda</h3>
   <p class="slide-body right">asdasd asdasdas asdasd adasd asdasd adsad asdsad adas asdasdasdsa asdasdasda asdasd asdasdsadsadasd asdasdas asdasd adasdas asdsada asda.</p>
   </div>
 </div>
</div>
<div style="background-color: yellow;">
<p>I'm the next element. But, for some reason, my background color doesn't touch the other element on IE7 and IE8. Float may remove it... but a float here will perhaps mess this all up...</p>
</div>

Conditional IE 7 Inline-Block issue:

#slide2 .column {
    zoom: 1;
    display: inline;
}

This is almost there. But I still have a bottom gap between the bottom of the columns and the next element.

Any clue?

Just now I saw your post. I’m still unable to see the image, and I have changed the strategy on my last code.
The issue about this last one, is that, well… you have to absolute position all the text, and it’s not at all flexible… (but neither was the other any anyway…).

Not sure what path to take, none seems good to me to be honest. :frowning:

I will take a second look on the first approach. It seems better then the second… but if anyone could look at the layout on the first post, and tell me that I REALLY should take another approach, please spare me a few more hours… :smiley:

The first version posted:

This is how I see it on IE8 standard mode. No images.

(I will get back in 9 hours).

Before I go:

I tried this now with absolute positioning. Still no background images appearing. :s

#container1 {
    background-color: red;
    text-align: center;
}

.main-column {
    display: inline-block;
}

.main-column h2 {
    width: 220px;
    height: 235px;
    padding-top: 110px;
    position: absolute; /* <<-- Changed */
    background: url('http://s24.postimg.org/ossqwb7hh/carica_Kairos.png') no-repeat top center;
    margin: 0 auto;
}

.text-column {
    width: 220px; /* <<-- Make it equal to the h2 */
    height: 300px;
    background-color: yellow;
    margin: 120px auto 0 auto;
    padding-top: 270px; /* <<-- Adjust */
}

.text-column p {
    padding: 0 50px;
}

Do you have ANYTHING in your code that might hide the image?

img {display:none;} ?

img {visibility:hidden;} ?

img {opacity:0} ?

img {margin-left:-9999px} ?

ANYTHING?

The image is certainly visible in the fiddle demo. Can you not see it in your browser?

EDIT:

Just noticed that you have “top” and “center” in the wrong order… should be “center top”…

@rontap - The fiddle works and I can see it on fiddle. But, the problem lies on IE7 and IE8. And that I can’t see with fiddle, so I copy paste the code above, and uploaded and the result was the one on the image.

Anything related to hidden images.

I did had some containers with overflow: hidden; I have them no more.

Still the same issue.

I’ve uploaded the all code here:

http://dev.kairos.org.pt

Please note that you scroll down, until you find the portion with the red background.
Before that I have another try, it almost work cross browser, but it’s so painfull to maintain that I’m trying another approach.

So, and to sum all up:

  1. We can float the three columns left, but then I need to center floated elements, and normally, we get more trouble then solutions on that path. (try it, no dice so far).
  2. I can insist on float left those three columns, but have no background associated on each of those columns, and have the container background with the “three columns” as an image.
    • But this will not make much sense, because if we have the content floated, it will drop uppon resize, but the same will not occur with the image.
  3. I can forget the float and concentrate on display inline-block and hack it on IE7 with zoom:1; and display:inline;
    I can display inline block the text elements; Build the columns with CSS; and Try to center them all, and just use the rounded image. - Try it already here.
    I can use the ALL column as an image, and display inline block the text elements. Try it already here.
    I can use the ALL three columns as an image on a container, and then, display inline-block the elements. - Less flexible, and the reason why I’ve not tried this.

I’m running out of options… :s

@ronpat - I change the absolute remote path and placed a relative image on the background declaration for the sake of your argument. And I’m now able to see the image.
So, apparently, so I hope, this code is a good candidate to achieve the layout on top.

I rest my case for the moment. Thanks a lot for looking into it.

I did not see a red background until now, so whatever you changed has made a big difference. Something was preventing the red background in container1 from rendering in my browser. Good show!

Just for fullish perfectionism, here’s another try, now with position relative.

It seems easier to deal with, then with the position absolute alternative.
Same html structure.


 #container1 {
    background-color: red;
    text-align: center;
}
 
.main-column {
    display: inline-block;
    width: 300px;
}
 
.main-column h2 {
    padding-top: 110px;
    padding-bottom: 110px;
    background: url('../images/caricaKairos.png') no-repeat center top;
    margin: 0 auto;
    position: relative; /*so that the image stays on top. - WHY this works? Don't know.'*/
}
 
.text-column {
    width: 215px;
    background-color: yellow;
    margin-top: -120px; /*so that it enters inside the h2*/
    padding-top: 120px;
    margin-left: auto;
    margin-right: auto;
}
 
.text-column p {
    padding: 0 50px;
}

Why position: relative; on H2 makes the background on front, is beyond my understanding. Any clue?
Got it. It makes it have z-index: 0, and due to that, it ignores is markup position, hence, staying on top of static default other elements.

Well, I do understand that the stacking context is changed when an objects is ‘positioned’ and {position:relative} is commonly used for that very purpose. It will move the object to which it is applied near the top of its containing stack.

Ok.

I place all real information there, and by doing that, I was able to see some limitations.
I added a new element on the markup, a container for the h3 to sit the background there.

Please take a lot on the tree yellow columns:

.project-table and children:

http://dev.kairos.org.pt

One issues (update):

  1. Columns don’t properly sit on the bottom once I add (so I guess) overflow: hidden;

Any clue?

That’s just the white-space you get with inline-block. Try this:


.main-column{vertical-align:bottom}

I would have used display:table and table-cell for the equal columns and avoid the in page link bug you get with those massive negative margins. It would also ensure that no matter how much text you have the columns always stay equal unlike your current method. Of course display:table is only IE8+ but you shouldn’t spend too much time on hacking for IE7 as usage is low and unequal columns are no big thing (but you could of course use your method for IE7 and under only).

@Paul O’B I’m aware of that bug but none of those columns will have links.
However, and for the sake of learning, I’ve never used display:table, mainly due to the ie7 limitation, but, since you mentioning, however, that I can use this margin/bottom technique on IE7, while on IE8 and up, the display table. That seems a good approach, I’m just not sure how different will/should the IE7 conditional css be, but I will give it a try.

About the vertical-align bottom, that white space is a white space given to inline-block elements for the letter descendents?
(I end up given line-height: 0 on the container, and specify the line-height on the inner elements, but… well… if vertical-align: bottom makes it… what can I say :D).

Again, I will give a try with display: table and let know about the results.

Draft: display table 1

I’ve made a few changes and the page behave, however, I believe I need more display table cells on this code.
While this works, and was made with minor changes, the text position still depends a lot on margins and padding values.

It would also ensure that no matter how much text you have the columns always stay equal unlike your current method.

Can you please elaborate further on that?

/* Display Table try*/
.project-table {
    margin: 0 auto; /*<<-- Added instead of text-align: center;*/
    display: table; /*<<-- Added */
}
 
.project-table .main-column {
    display: table-cell; /*<<-- Added */
    min-width: 300px;
}

.project-table .main-column .header-column {
    height: 235px;
    background: url('someImageHere.png') no-repeat center top;
    position: relative; /*will give z-index of 0 and place this element on front*/
}

.project-table .main-column .header-column h3 {
    margin: 0 auto;
    padding-top: 85px;
    width: 170px;
    text-align: center;
    text-transform: uppercase;
    font-size: 1.25em;
    font-family: Arial;
    line-height: 1.2;
}
 
.project-table .text-column {
    width: 215px;
    background-color: #FCE17B;
    margin-top: -120px; /*so that it enters inside the h2*/
    padding-top: 140px;
    margin-left: auto;
    margin-right: auto;
    min-height: 200px;
    
}
 
.project-table .text-column p {
    font-size: 1em;
    font-family: Arial;
    padding: 20px 10px 0 10px;
    line-height: 1.2;
}

Thanks again.

You need a structure roughly like this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
body { background:rgba(104, 156, 153, 0.9) }
.table-wrap {
	width:960px;
	border:1px solid #000;
	overflow:hidden;
	margin:20px auto;
}
.wrap {
	display:table;
	width:960px;
	table-layout:fixed;
	border-spacing:88px 0;
	height:200px;
	text-align:center;
	margin-left:-88px;
}
.column {
	background:#FCE17B;
	display:table-cell;
	vertical-align:middle;
	width:261px;
	padding:25px 0;
}
.column p { padding:0 25px }
</style>
</head>

<body>
<div class="table-wrap">
		<div class="wrap">
				<div class="column">
						<p>Acessível a todas as associações de animais abandonados a nível nacional.</p>
				</div>
				<div class="column mid">
						<p>De modo a propiciar e aumentar significamente o número de adopções responsáveis.</p>
				</div>
				<div class="column">
						<p>De forma a sensibilizar, divulgar e instigar o esclarecimento de questões que promovam e permitam a mudança de paradigmas culturais obsoletos.</p>
				</div>
		</div>
</div>
<div class="table-wrap">
		<div class="wrap">
				<div class="column">
						<p>Acessível a todas as associações de animais abandonados a nível nacional.</p>
				</div>
				<div class="column mid">
						<p>De modo a propiciar e aumentar significamente o número de adopções responsáveis.</p>
				</div>
				<div class="column">
						<p>De forma a sensibilizar, divulgar e instigar o esclarecimento de questões que promovam e permitam a mudança de paradigmas culturais obsoletos.</p>
						<p>De forma a sensibilizar, divulgar e instigar o esclarecimento de questões que promovam e permitam a mudança de paradigmas culturais obsoletos.</p>
						<p>De forma a sensibilizar, divulgar e instigar o esclarecimento de questões que promovam e permitam a mudança de paradigmas culturais obsoletos.</p>
				</div>
		</div>
</div>
</body>
</html>


The challenge is making the space between cells which is achieved through border-spacing and then offsetting the difference with a negative left margin.

Can you please elaborate further on that?

Yes, just increase your text content to more than 200px and all your columns become uneven - unlike the ones in my demo above.

Please Paul O’B don’t take me wrong. I have registered a possible way of doing it using tables and I realize the limitations of my earlier approach.
But if I change now the markup and the css overall structure I would need a lot more hours that the ones I have to offer for properly solving this.
Since we are not having any links inside those columns, and since this is already working on IE7, IE8 I will take that road.
IE7 is still something to consider, and it would also take some time to proper make those columns side by side on IE, since the “display:inline” will not do. I would perhaps need to go on float…

Again, I will take your last structure code, on a project where I can rely from the very beginning on display:table; and your suggestion.

Thank you all, for your time here and again, sorry for not being able to follow the display:table; path.