How to make custom sidebar position fixed

Raza Poonja

This is My code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE-edge">
    <meta name="viewport" content="width = device-with, initial-scale = 1">
    <title>Tittle</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

        <style>

                body, html, .sidebar, .body {
                height: 100%;
                min-height: 100%;
                margin: 0;
                padding: 0;
                }

                #container {
                    width: 100%;
                    height: 100%;
                }

                .sidebar {
                    background-color: green;
                    width: 10%;
                    float: left;
                    height: 100%;
                    //position: fixed;
                }

                .body {
                    float:left;
                    width:90%;
                    height:100%;
                }

        </style>

</head>
    <body>

        <div id="container">
            <div class="sidebar">

            </div>

            <div class="body">

                        <div id="Div">
                            <img src="http://www.wallpapereast.com/static/cache/85/2f/852fa0958af9bfca3e64fa66aa1ad907.jpg" alt="image" width="100%" height="1200px"/>
                        </div>

            </div>

            </div>
        </div>

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    </body>
</html>

This code works perfectly but I want the sidebar to be fixed at its position when user is scrolling the page here the output

enter image description here

I tried this CSS property

postion: fixed;

and this is the Output

enter image description here

I need help cant'figure out what to do and I have searched alot but can't find suitable solution

Johannes

try to add margin-left: 10% to your .body class (and delete the floatfor it)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make a fixed menu/sidebar while using position:relative?

From Dev

Make sidebar positioning fixed

From Dev

How to simulate 'position:fixed' behavior on Flexbox-aligned sidebar

From Dev

CSS - How to position a fixed sidebar div relatively to a centered content div

From Dev

CSS - How to position a fixed sidebar div relatively to a centered content div

From Dev

How to simulate 'position:fixed' behavior on Flexbox-aligned sidebar

From Dev

#sidebar position:fixed at certain scrolling

From Dev

How to make a fixed width sidebar align with the flexible content using flexbox

From Dev

How to make fixed position row in bootstrap?

From Dev

How to make background position fixed and centered?

From Dev

How to make position fixed div scroll horizontally?

From Dev

My sidebar is fixed no matter what. How do I make scrolling possible with the sidebar?

From Dev

How make a fixed element be on top of another position fixed element

From Dev

Flex Layout with fixed position (no scrolling) sidebar

From Dev

Position fixed sidebar with overflow scroll not scrolling to bottom

From Dev

Bootstrap 4: Fixed position sidebar overlapped by the content

From Dev

Flex Layout with fixed position (no scrolling) sidebar

From Dev

How to position sidebar in bootstrap?

From Dev

How to adjust the sidebar position?

From Dev

Make a position fixed not scrollable

From Dev

Make tooltip position fixed

From Dev

How can I make position:fixed work on iOS 7?

From Dev

How do I make the child-div to have a fixed position?

From Dev

How to position an element at the bottom of the screen on load but not make it fixed?

From Dev

How can I make position:fixed work on iOS 7?

From Dev

How to make box bigger in CSS3, with the position of text fixed?

From Dev

how to make the position of div is fixed even though it's empty?

From Dev

How can I make position fixed for span under li

From Dev

How to make div to overlay browser viewport without fixed position?

Related Related

  1. 1

    How to make a fixed menu/sidebar while using position:relative?

  2. 2

    Make sidebar positioning fixed

  3. 3

    How to simulate 'position:fixed' behavior on Flexbox-aligned sidebar

  4. 4

    CSS - How to position a fixed sidebar div relatively to a centered content div

  5. 5

    CSS - How to position a fixed sidebar div relatively to a centered content div

  6. 6

    How to simulate 'position:fixed' behavior on Flexbox-aligned sidebar

  7. 7

    #sidebar position:fixed at certain scrolling

  8. 8

    How to make a fixed width sidebar align with the flexible content using flexbox

  9. 9

    How to make fixed position row in bootstrap?

  10. 10

    How to make background position fixed and centered?

  11. 11

    How to make position fixed div scroll horizontally?

  12. 12

    My sidebar is fixed no matter what. How do I make scrolling possible with the sidebar?

  13. 13

    How make a fixed element be on top of another position fixed element

  14. 14

    Flex Layout with fixed position (no scrolling) sidebar

  15. 15

    Position fixed sidebar with overflow scroll not scrolling to bottom

  16. 16

    Bootstrap 4: Fixed position sidebar overlapped by the content

  17. 17

    Flex Layout with fixed position (no scrolling) sidebar

  18. 18

    How to position sidebar in bootstrap?

  19. 19

    How to adjust the sidebar position?

  20. 20

    Make a position fixed not scrollable

  21. 21

    Make tooltip position fixed

  22. 22

    How can I make position:fixed work on iOS 7?

  23. 23

    How do I make the child-div to have a fixed position?

  24. 24

    How to position an element at the bottom of the screen on load but not make it fixed?

  25. 25

    How can I make position:fixed work on iOS 7?

  26. 26

    How to make box bigger in CSS3, with the position of text fixed?

  27. 27

    how to make the position of div is fixed even though it's empty?

  28. 28

    How can I make position fixed for span under li

  29. 29

    How to make div to overlay browser viewport without fixed position?

HotTag

Archive