radiocaf
radiocaf

Reputation: 151

I've moved to CSS from Tables, and having a couple of issues with lining things up

Backstory

So a couple of years ago for the younger members of my family, I hosted a small website on my NAS that allowed them to create a Christmas wishlist that other family members could then go on and choose what they wanted to buy, and mark the item as theirs to prevent double or erroneous purchases. It worked well, and was greatly received, so I am trying to update it's layout to be responsive as some people want to access it from mobile devices. It was basic code, not very secure and used tables.

So now I am trying to update the website to be more modern and responsive, as well as a little bit secure (I've never had any problems with people messing with the website, but it's a potential threat so I'd rather nip it in the bud before it starts.)

Question

I SELECT all rows from a MySQL database and display them in a list. I used to use tables to keep it all laid out and looking nice, but I'm trying to move to CSS, so that the website can be more efficient and responsive.

I have the basic layout sorted but I have a few snagging issues. Here is the fiddle of how it looks now:

https://jsfiddle.net/0q10uhw1/11/

What I need it a layout similar to this, which is how it used to look when there was tables being used for the layout: Layout Example

Each row returned was put into a table like that, one under another, list style. But now I'm getting rid of the tables in place of CSS, I'm struggling a tad.

The main issues I'm having at the moment are:

Upvotes: 0

Views: 65

Answers (1)

Navek
Navek

Reputation: 47

Issue #1

.container has white-space:nowrap; so the content won't wrap when it reaches the edge. Set it to wrap or pre-wrap.

.container {
white-space: wrap;}

Issue #2

.name needs to be float:left, so it will take up the space to the immediate right of the image and allow the price to float to the space on the right.

So it also needs to have a width assigned to it to allow the other elements space. Try something like 50% and then adjust.

.name {
display: inline-block;
text-overflow: ellipsis;
overflow: hidden;
float:left;
width:55%;}

Issue #3

This can be solved by using your clear divs with clear:both and using them as dividers outside the content containing divs, not inside like you have used.

This should get you back on track. https://jsfiddle.net/0q10uhw1/15/

Upvotes: 1

Related Questions