Forums

[resolved] center image with CSS (5 posts)

  1. alexandre596
    Member
    Posted 1 year ago #

    I have a little problem centralizing image on wordpress
    I mean, I don't have actually, I could simply use <center> tag, and it'll work just fine, but I want to make it faster haha

    I mean, on CSS I have on style, newwpstyle and all my posts go on that style, right?
    and ALL image with links, is ALWAYS centralized...
    so, instend of editing the code, and put the center tag on the pic, I want to make it faster, to every image with link, already put it on the center... here the CSS code that i'm using

    .newwpstyle a img {
    	display: block;
    	margin-left: auto;
    	margin-right: auto
    }

    it kinda works, the image is on the center, but each image in one different line, when they need to be all on the same line...

    I tried with display: inline; and display: table;
    both don't worked...
    I also tried text-align:center;
    don't work too =/
    any ideas?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Unless you provide a link to a page demonstrating the problem, no one will be able to offer much in the way of assistance.

  3. alexandre596
    Member
    Posted 1 year ago #

    sorry, here it is..

    http://78violet.org/english/?p=143

    see?? the images are on different lines, when they should be on the same...

    anyway, here is the source code, IDK if it'll help, but..

    [Code moderated as per the Forum Rules. Please use the pastebin]

  4. Laurie
    Member
    Posted 1 year ago #

    The display:block; in your style is causing the line breaks - display:block means it takes up the whole width of the containing element.

    If I change this to display:inline; in Firebug, it lines them up how you want them. To center them in the paragraph, you'd need to make that paragraph text-align:center;. What I do is create a class called 'centered' with just this style on it, and then assign this class every time I want something centered.

    Hope that helps!

  5. alexandre596
    Member
    Posted 1 year ago #

    working just fine

    THANK YOU

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.