background-image doesn't appear if
is empty?

前端 未结 8 1053
旧巷少年郎
旧巷少年郎 2020-12-07 01:11

I created a

first thing in the to draw a top line at the top of the page:


    
8条回答
  •  [愿得一人]
    2020-12-07 01:56

    The best way I have found is: for landscape:

    width:100%;
    height:0;
    padding-top:[ratio]%;
    

    for portrait:

    width:[ratio]%;
    height:0;
    padding-top:100%;
    

    You need to determine which side is longer and accept this dimension as 100% then calculate [ratio] - percentage of shorter dimension in relation to 100% longer dimension. Then use the one of solutions above.

提交回复
热议问题