Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Get Percentage Height To Work on Li Elements And Maintain Image Aspect Ratio Inside Li Elements

Get Percentage Height To Work on Li Elements And Maintain Image Aspect Ratio Inside Li Elements

Scheduled Pinned Locked Moved Web Development
htmlquestionmobiledatabasearchitecture
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Liagapi
    wrote on last edited by
    #1

    I have a responsive web page where there are images inside a horizontal unordered list. I want my web page to shrink/stretch when the page resolution changes so I did not set the width or height of any page elements using pixels. Below are my media query and markup:

    media screen and (min-width: 320px) {
    html, body{width:100%;height:100%;}
    #banner{width:100%;height:10%; border:1px solid blue}
    #largeImage{width:100%;height:70%; border:1px solid blue}
    #picsContainer{width:100%;height:10%; border:1px solid blue}
    img{width:100%;height:auto}
    ul{list-style:none}
    ul li{width:10%;height:100%; display:inline-block; border:1px solid blue}
    footer{width:100%;height:10%;border:1px solid blue}
    }


    image

                *   ![image1](pic/img1.jpg)
                *   ![image2](pic/img2.jpg)
                *   ![image3](pic/img3.jpg)
                *   ![image4](pic/img4.jpg)
                *   ![image5](pic/img5.jpg)
                *   ![image6](pic/img6.jpg)
                
            
    
        
    
        
    
           Footer
    

    I have just two questions: 1 - How do I get height:100% to work on ul li elements without giving a pixel width to their parent or grand parent? 2 - How do I maintain aspect ratio for images inside li elements?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups