CSS content / please help :)

Discussion in 'HTML & Website Design' started by MaxTitan, Jul 16, 2013.

  1. #1
    I want my content box class to expand to the amount of text it has in it on different pages so I don't have to make a new div id for every page. How would I make it do that?

    #content {
        margin: auto;
        background-color: #FFF;
        border-radius:5px;
        position: relative;
        width: 1000px;
        height: 525px;
        padding: 10px;
        box-shadow: 0 0 20px rgba(0,0,0,0.4);
    }
    Code (markup):

     
    Solved! View solution.
    MaxTitan, Jul 16, 2013 IP
  2. #2
    Do you mean "expand" the height?

    Pretty simple - remove the "height" and replace it with "min-height".

    With min-height, you have a guaranteed minimum height. If the text is "higher" than that, the div will expand.
     
    GMF, Jul 17, 2013 IP
  3. Vernard

    Vernard Member

    Messages:
    92
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #3
    You can try setting the width & height to auto and then increase the padding if needed.
     
    Vernard, Jul 17, 2013 IP
  4. blingcityusa

    blingcityusa Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    yes GMF is right... It will be easy for you if you keep "min-height" at given px it will remain at that px and it will increases as the length of the text increases
     
    blingcityusa, Jul 17, 2013 IP
  5. xeod

    xeod Greenhorn

    Messages:
    47
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    23
    #5
    #content {
        margin: auto;
        background-color: #FFF;
        border-radius:5px;
        position: relative;
        width: 980px;
        padding: 10px;
        box-shadow: 0 0 20px rgba(0,0,0,0.4);
    }
    Code (markup):
    I've modfied the width of the container ( to be exactly 1000px wide ). But it's 980px, how's that possible ? Well, when you add paddings to an element and you have a specified width it simply adds ( width and height ).The 'secret' is to substract the padding that goes on the sides ( padding-right & padding-left ).So 10px padding left + 10px padding right subtracted from 1000px = 980px.
     
    xeod, Jul 17, 2013 IP
  6. MaxTitan

    MaxTitan Member

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #6

    Sweet thanks again :) and I figured out the other problem it was supposed to be set to "all" in order for it to minimize with the same speed.
     
    MaxTitan, Jul 17, 2013 IP