开发者

How to make a div always on the left-most side of the browser window?

开发者 https://www.devze.com 2023-01-08 01:45 出处:网络
I want to make make a div always showing on the left-most s开发者_如何转开发ide of the browser window, ], would you give me some hints?Try this:

I want to make make a div always showing on the left-most s开发者_如何转开发ide of the browser window, ], would you give me some hints?


Try this:

div#mydiv {
    position: fixed;
    left: 0;
}

You'll probably want to add top or bottom to that as well so that it doesn't sit at the top of the screen.

Something like:

div#mydiv {
    position: fixed;
    left: 0;
    top: 200px; /* 200px from top */
}

or:

div#mydiv {
    position: fixed;
    left: 0;
    bottom: 200px; /* 200px from bottom */
}

or:

div#mydiv {
    position: fixed;
    left: 0;
    top: 50%; /* Half way down the side */
}


set its position to fixed and its left to 0px

#fixedLeft{
    position:fixed; /* now it will stay fixed on the screen, even while you scroll*/
    left:0px; /* it will be stuck to the left*/
    top:50%; /* it will be in the middle (vertically)*/
}
0

精彩评论

暂无评论...
验证码 换一张
取 消