Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    264
    Thanks
    49
    Thanked 1 Time in 1 Post

    Why isn't this Div correctly sized?

    This webpage is produced by Wordpress.

    The content to product the first image of people standing on a tree stump is:
    Code:
    [caption id="attachment_887" align="alignnone" width="620"]
      <a href="http://steven.doig.com.au/files/2013/06/Forest_Legacy_m.jpg">
        <img class="size-large wp-image-887" alt="a Forest Legacy group" src="http://steven.doig.com.au/files/2013/06/Forest_Legacy_m-1024x681.jpg" width="1024" height="681" />
      </a> a Forest Legacy group[/caption]
    I have the following CSS code:
    Code:
    #content .wp-caption a img {
    	width: 614px;
    	height: auto;
    }
    .wp-caption {
    	margin-bottom: 10px;
    	padding: 3px;
    	background-color: rgba(255,255,255,.1);
    }
    Why isn't the caption div width 620px?

    The front end is producing the code:
    Code:
    <div id="attachment_887" class="wp-caption alignnone" style="width: 630px">
    What is producing
    Code:
    style="width: 630px"
    ?

    Thanks
    Last edited by SRD75; 07-10-2013 at 02:08 PM.

  • #2
    Regular Coder
    Join Date
    Mar 2013
    Posts
    262
    Thanks
    4
    Thanked 67 Times in 67 Posts
    If you look into the core WP files (more specifically media.php), you'll see that WP automatically adds 10 to the width.

    So if you have
    Code:
    width="620"
    It will actually produce
    Code:
    style="width: 630px">
    Take a look at the img_caption_shortcode function in the media.php file to see what I'm talking about. It adds 10 to your width.

    You can either just automatically subtract 10 from your desired width or use some plugin.
    My signature :)

  • Users who have thanked ttkim for this post:

    SRD75 (07-10-2013)

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    264
    Thanks
    49
    Thanked 1 Time in 1 Post
    Thanks once more ttkim.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •