Full page background image with vertical scrolling

后端 未结 2 1553
旧巷少年郎
旧巷少年郎 2021-01-31 00:24

I\'m trying to create a page where the background image is responsive to your browser\'s screen size. However, I need content under that image such that if the person scrolls do

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 01:10

    Try this Fiddle:

    HTML:

    Content

    Use absolute positioning to make the background image the same size as the screen, and put the content after, with a top of 100%:

    body { 
        margin:0;
    }
    .image {
        position:absolute;
        width:100%; 
        height:100%; 
        background:green;
        background-image:url('some-image.jpg');
        background-size:cover;
    }
    .content {
        position:absolute; 
        width:100%; 
        top:100%; 
        height: 100px;
    }
    

提交回复
热议问题