How do i make the sidebar responsive

Timo B.

I hope this code is alright, I'm a beginner. I have the blue sidebar on the right which for one is too low and also not responsive, I'm not sure how to code these things. Thank you very much!

html {
 font-family: "Trebuchet MS", Helvetica, sans-serif;
 color: #424242;
}

body {
  background-color: #D5FAFB;
  margin-top: 35px;
  margin-right: 50px;
  margin-left: 50px;
}

.text {
  margin-right: 800px;
}

img {
  float: right;
  border: 5px solid black;
  margin-right: 500px;
}

h1 {
 color: #232424;
 font-size: 50px;
 text-align: center;
}

.sidebar {
  float: right;
  background-color: #3399FF;
  padding: 30px;
  font-size: 30px;
  margin-bottom: 300px;

}
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="css/new-styles.css" media="all">
    <title>How to take care of Fido</title>
  </head>

  <body>
    <h1>Instructions for Fido's babysitter</h1>

    <h2>Thanks so much for watching Fido this weekend! Here's everything you need to know while I'm gone.</h2>

    <img class="image" src="img/helsinki.jpg">

    <div class="text">
      <p>Here's a bit of history about Fido. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

      <p> Fido is allergic to a lot of foods.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

      <p>Fido likes to play. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

      <p>Here is a list of things that you should do with Fido every day.</p>
    </div>

    <div class="sidebar">
      <p>Menu</p>
      <p>Picture</p>
      <p>Videos</p>
      <p>Contact</p>
    </div>

    <ul>
      <li>Walk him</li>
      <li>Feed him</li>
      <li>Pet him</li>
    </ul>

    <p>If you have any questions while i'm out of town, I <strong>won't have cell service</strong> but you can<a href="mailto:[email protected]" class="btn btn-primary btn-lg" role="button"> email me</a> if you need anything</p>

    <p>Thanks again!</p>
  </body>
</html>

rafaelcastrocouto

SOLUTION

I'm not sure this is what you were looking for ... but it's pretty and working just fine.

.sidebar {
  position: fixed;
  top: 20%;
  right: -170px;
}
.sidebar:hover {
  right: 0;
}

html {
 font-family: "Trebuchet MS", Helvetica, sans-serif;
 color: #424242;
}

body {
  background-color: #D5FAFB;
  margin-top: 35px;
  margin-right: 50px;
  margin-left: 50px;
  min-width: 200px;
  overflow-x: hidden;
}


img {
  float: right;
  border: 5px solid black;
  margin-right: 500px;
}

h1 {
 color: #232424;
 font-size: 50px;
 text-align: center;
}

.sidebar {
  opacity: 0.9;
  position: fixed;
  top: 20%;
  right: -170px;
  background-color: #3399FF;
  padding: 30px;
  font-size: 30px;
  margin-bottom: 300px;
  border-radius: 5px 0 0 5px;
  transition: right 0.5s ease-in-out;
}
.sidebar:hover {
  right: 0;
}
.sidebar p {
  margin: 5px;
  padding: 10px;
}
.sidebar p:hover {
  background-color: rgba(255,255,255,0.3);
}
.sidebar > span {
  color: white;
  position: absolute;
  left: 4px; top: 45%;
}
.sidebar > span {
  color: white;
  position: absolute;
  left: 4px; top: 45%;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
}
.sidebar:hover > span {
  opacity: 0;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<h1>Instructions for Fido's babysitter</h1>

    <h2>Thanks so much for watching Fido this weekend! Here's everything you need to know while I'm gone.</h2>

    <img class="image" src="img/helsinki.jpg">

    <div class="text">
      <p>Here's a bit of history about Fido. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

      <p> Fido is allergic to a lot of foods.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

      <p>Fido likes to play. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>

      <p>Here is a list of things that you should do with Fido every day.</p>
    </div>

    <div class="sidebar">
      <p>Menu</p>
      <p>Picture</p>
      <p>Videos</p>
      <p>Contact</p>
      <span>«</span>
    </div>

    <ul>
      <li>Walk him</li>
      <li>Feed him</li>
      <li>Pet him</li>
    </ul>

    <p>If you have any questions while i'm out of town, I <strong>won't have cell service</strong> but you can<a href="mailto:[email protected]" class="btn btn-primary btn-lg" role="button"> email me</a> if you need anything</p>

    <p>Thanks again!</p>
</body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do I make the navbar responsive depending on the viewport?

From Java

How do I make my absolute-positioned elements responsive?

From Dev

How do I keep this sidebar stationary yet still responsive?

From Dev

How do I make a Pinterest Widget Builder Responsive?

From Dev

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

From Dev

How do I make rails form responsive to a hyperlink?

From Dev

How do I make this responsive layout with CSS?

From Dev

How do I make this code more responsive?

From Dev

How do I make a Sidebar display values from cells?

From Dev

How do I make a background image responsive?

From Dev

On a sidebar, how do I make the secondary menu open up next to the first-level menu?

From Dev

How do I make semantic ui pages responsive?

From Dev

How do I remove YouTube sidebar integration?

From Dev

How can I convert an already created sidebar into a responsive design?

From Dev

How do I remove YouTube sidebar integration?

From Dev

How do I make my website's background image responsive?

From Dev

How do I make a website responsive?

From Dev

How do I make this right content responsive?

From Dev

How to remove sidebar to make web page more responsive

From Dev

How do I make rails form responsive to a hyperlink?

From Dev

how do i make this responsive nav bar work properly?

From Dev

On a sidebar, how do I make the secondary menu open up next to the first-level menu?

From Dev

How do I make custom .desktop files behave correctly in the Gnome 3 sidebar?

From Dev

How do I make semantic ui pages responsive?

From Dev

How to make a responsive single page website with sidebar?

From Dev

How to make image sidebar responsive

From Dev

How do I make a responsive div with scroll content in HTML?

From Dev

What could I do to make this menu responsive?

From Dev

Angular 5: How do I create a responsive sidebar?

Related Related

  1. 1

    How do I make the navbar responsive depending on the viewport?

  2. 2

    How do I make my absolute-positioned elements responsive?

  3. 3

    How do I keep this sidebar stationary yet still responsive?

  4. 4

    How do I make a Pinterest Widget Builder Responsive?

  5. 5

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

  6. 6

    How do I make rails form responsive to a hyperlink?

  7. 7

    How do I make this responsive layout with CSS?

  8. 8

    How do I make this code more responsive?

  9. 9

    How do I make a Sidebar display values from cells?

  10. 10

    How do I make a background image responsive?

  11. 11

    On a sidebar, how do I make the secondary menu open up next to the first-level menu?

  12. 12

    How do I make semantic ui pages responsive?

  13. 13

    How do I remove YouTube sidebar integration?

  14. 14

    How can I convert an already created sidebar into a responsive design?

  15. 15

    How do I remove YouTube sidebar integration?

  16. 16

    How do I make my website's background image responsive?

  17. 17

    How do I make a website responsive?

  18. 18

    How do I make this right content responsive?

  19. 19

    How to remove sidebar to make web page more responsive

  20. 20

    How do I make rails form responsive to a hyperlink?

  21. 21

    how do i make this responsive nav bar work properly?

  22. 22

    On a sidebar, how do I make the secondary menu open up next to the first-level menu?

  23. 23

    How do I make custom .desktop files behave correctly in the Gnome 3 sidebar?

  24. 24

    How do I make semantic ui pages responsive?

  25. 25

    How to make a responsive single page website with sidebar?

  26. 26

    How to make image sidebar responsive

  27. 27

    How do I make a responsive div with scroll content in HTML?

  28. 28

    What could I do to make this menu responsive?

  29. 29

    Angular 5: How do I create a responsive sidebar?

HotTag

Archive