Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-02-10 12:23:59

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

css image alignment

Can anyone see how I need to add or change the css for photos like this so they are centered?

http://www.jameslomax.com/photos/2730/maiden-moor-to-newlands-valley

- the rest of the photos have to stay the way they are.

I guess the css has to be specific for those panorama photos in some way, but I don’t know how you do that.

As I recall – but I may be wrong – all the photos appear in some kind of ‘container’ which means this one fills the container and then overflows to the right.

Thanks!

Offline

#2 2015-02-10 12:57:05

alivato
Member
Registered: 2011-03-31
Posts: 151

Re: css image alignment

p#single-photo {
  width: 796px;
  height: auto;
}
#thumbs a img {
}
p#article-image img { 
}

Last edited by alivato (2015-02-10 12:57:39)

Offline

#3 2015-02-10 13:08:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: css image alignment

You could tweak your markup, because the fixed-width container is scuppering things.

Failing that, although not ideal, to get you closer you can remove the three rules from inside the following CSS blocks:

div#page {
   width: 820px;
}

and:

div#wrapper {
   width: 726px;
   margin: 0px auto;
}

then add a new rule block:

div#thumbs {
   width: 726px;
   margin: 0 auto;
}

But if you do that, your text between the top pic and the thumbnails will spill out full width so you’ll probably need to wrap a new div around those and set it to have the same width as div#thumbs to rein it in a bit. You might have to rethink the floats too, they’ll probably depend on your position:relative settings.

Fixed-width designs tend to have annoyances like this, but it’s difficult to simulate in the browser’s inspector without the markup actually being changed. But I’m sure someone else can come up with something better.

EDIT: like alivato for instance :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2015-02-10 13:32:53

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: css image alignment

Here’s how I do centered images without breaking too much inherited stuff: display:block;margin-left:auto;margin-right:auto;.

Offline

#5 2015-02-10 14:55:44

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: css image alignment

Thanks. Tried inserting both alivato and gaekwad code – no joy.

Then tried deleting what I thought (guessed) needed deleting in existing css (‘container’ etc) – no joy.

Might try again later. Or if anyone has a view minutes and could insert the code I need into the style appropriately – so I can just insert it into txp – that would be great.

Incidentally, and this may change things, I’ve wanted to style the text below the photos for a long time (as bloke refers to) but didn’t know how to do it.

Offline

#6 2015-02-10 14:59:18

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: css image alignment

Resize the image? It’s a fixed-size layout, so that’ll help.

Offline

#7 2015-02-10 17:18:18

etc
Developer
Registered: 2010-11-11
Posts: 5,195
Website GitHub

Re: css image alignment

Try this old trick, who knows…

#single-photo {
    left: 50%;
    margin-left: -100%;
}

Offline

#8 2015-02-10 20:01:02

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,731
Website

Re: css image alignment

etc’s makes it nice and wide over the whole width. If you want it as wide the upper menu width, use alivato’s css suggestion with one small modification (the img in the wrapper should be targeted):

#single-photo img {
  width: 796px;
  height: auto;
}

If you want the image as wide as the grid of thumbs, use width:698px; instead.


TXP Builders – finely-crafted code, design and txp

Offline

#9 2015-02-10 21:25:20

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: css image alignment

…or set it as the background to a div instead of an img.

Offline

#10 2015-02-13 10:46:55

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: css image alignment

Hi folks. None of this has worked / I don’t quite know how to do it. To clarify: what I want is the long photo displayed 100% but centered.

Is it possible to remove the ‘container’ in some fashion, so all the photos ‘float’ on the page and can then be told to center?

More to the point – would that be easier to define in the css?

Offline

#11 2015-02-13 10:50:11

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,263
GitHub

Re: css image alignment

Try:

.parent {
    position: relative;
    overflow: hidden;
}

.child {
    position: absolute;
    top: -9999px;
    bottom: -9999px;
    left: -9999px;
    right: -9999px;
    margin: auto;

}

Offline

#12 2015-02-13 11:51:44

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: css image alignment

Hi James

I don’t understad your question. 100% and centered in relation to what?

See this image.

Offline

Board footer

Powered by FluxBB