Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS % to Px

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #46379
    Junni
    Member

    how can we convert % to pixels

    am using

    `

    (100%)

    (85%)

    `

    i want to convert that 85% to pixels how can i do that?

    #142717
    Paulie_D
    Member

    You can’t…not without javascript.

    …and in any case, why would you want to?

    #142735
    Junni
    Member

    actually am having trouble with my site, am using first sction with 100 % and in it a div with 85% and in it there are two divs one flaot left and the othr is float right, i dont know y but on low resolution left div is on left but the right one is under it so

    #142746
    Paulie_D
    Member

    Changing it to px won’t help….there is clearly something more basic wrong.

    Could you show us the problem…perhaps in Codepen?

    #142793
    Eric Gregoire
    Participant

    Well if the divs inside the 85% div are a fixed width in px, that could be your problem. Try making them a percentage that adds up to under 100% or equal to. If there are any margins or padding on the left or right of them, you could make those percentages as well and make sure the width, margin, and padding values all add up to under 100% or equal.

    You may want to avoid any min-width values as well if you’ve specified any.

    #142797
    SilverSerpent
    Participant

    Are you saying you want something like this? http://cdpn.io/AGIuq

    #142857
    Junni
    Member

    @Boogiesox yess the Div inside 85% ‘s div there are two divs first one is 50% and second one have 400px width.

    am trying to make it available to Codepen just wait a little bit @Paulie_D

    #142860
    Junni
    Member
    #142861
    Junni
    Member

    Now you can see if the Screen Width is full then it is good but when you Change Resolution then the text will go down to the picture

    #142868
    SilverSerpent
    Participant

    Your problem has to do with the 400px. 400px is fine at a large screen size, but once the container gets down to less than 800px wide then it breaks. This is because you have your left column set at 50%, but at less than 800px wide the 400px column takes up more than 50% of the space, meaning there isn’t room for both of them.

    You can either convert them both to percentages that add up to 100% or less, or use the flexbox capability to make the right column take up 400px and then the left column to fill the remaining space. Either way, you’re going to have to compromise on one of the two columns.

    #142961
    Eric Gregoire
    Participant

    If you change the column with the image to a percentage width, you could also set the width of the image inside it to 100% of the column and set height to “auto” so it scales with the column.

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘CSS’ is closed to new topics and replies.