CSS / HTML Отзывчивый Исправлена ​​навигация по боковой панели с прокручиваемым окном контента - PullRequest
0 голосов
/ 26 июня 2018

Я довольно прост в своем кодировании и работаю над проверкой концепции дизайна, которая имеет видимую функциональность. Для этого я хочу сделать фиксированное, адаптивное раскрывающееся меню CSS слева от окна, а основной текст - прокручиваемый контент.

Извинения за то, как это может быть исправлено. Я уже почти две недели играю с кодом этого раздела в одиночку, поэтому я не уверен, что все мои правки были удалены соответствующим образом / и т.д.

Я предполагаю, что это как-то связано со спецификой CSS, которую я использовал, но я не могу понять, в чем проблема - в настоящее время мои дисплеи не показывают изображение профиля для правая сторона экрана, но вместо этого перекрывается с фиксированной боковой панелью.

Классы "col-X" можно игнорировать, если только кто-то не может помочь с этим. Попытался использовать метод col spacing, но у меня возникли дополнительные проблемы со спецификой моего CSS при использовании дополнительного класса, поэтому я попытался использовать элементы ID и Class, которые я уже указал для упрощения.

* {
  box-sizing: border-box;
  font-family: "Istok Web", "Barlow Semi Condensed", Arial, Helvetica, sans-serif;
}

/*12 col style for responsive page

#col-1 {
  width: 8.33%;
}

#col-2 {
  width: 16.66%;
}

#col-3 {
  width: 25%;
}

#col-4 {
  width: 33.33%;
}

#col-5 {
  width: 41.66%;
}

#col-6 {
  width: 50%;
}

#col-7 {
  width: 58.33%;
}

#col-8 {
  width: 66.66%;
}

#col-9 {
  width: 75%;
}

#col-10 {
  width: 83.33%;
}

#col-11 {
  width: 91.66%;
}

#col-12 {
  width: 100%;
}

[id*="col-"] {
  float: left;
} */

/* Fixed sidenav, full height */

#sidenav {
  width: 25%;
  height: 100%;
  position: fixed;
  z-index: 1;
  left: 0;
  overflow-x: hidden;
  padding-top: 17%;
}

/*Strip the ul of padding and list styling*/

ul {
  list-style-type: none;
  margin: 0;
  padding: 2%;
}

/*Create a horizontal list with spacing*/

li {
  display: block;
  margin-right: 1px;
}

/*Style for menu links*/

li a {
  display: block;
  height: 50px;
  text-align: center;
  line-height: 50px;
  color: #fc9497;
  text-decoration: none;
}

/*Style for dropdown links*/

li:hover ul a {
  color: #85e2ff;
  height: 40px;
  line-height: 40px;
}

/*Hover state for dropdown links*/

li:hover ul a:hover {
  color: #00BDF8;
}

/*Hide dropdown links until they are needed*/

li ul {
  display: none;
}

/*Make dropdown links vertical*/

li ul li {
  display: block;
  float: none;
}

/*Prevent text wrapping*/

li ul li a {
  width: auto;
  min-width: 100px;
  padding: 0 20px;
}

/*Display the dropdown on hover*/

ul li a:hover+.hidden,
.hidden:hover {
  display: block;
}

/*Style 'show menu' label button and hide it by default*/

.show-menu {
  text-decoration: none;
  color: #85e2ff;
  text-align: center;
  padding: 10px 0;
  display: none;
  float: left;
}

/*Hide checkbox*/

input[type=checkbox] {
  display: none;
}

/*Show menu when invisible checkbox is checked*/

input[type=checkbox]:checked~#menu {
  display: block;
}

/*Responsive Styles*/

@media screen and (max-width: 760px) {
  /*Make dropdown links appear inline*/
  ul {
    position: fixed;
    top: 0;
    width: 100%;
    display: none;
    padding-top: 20px;
    float: left;
  }
  /*Remove col-3 width for total page width
  #col-3 {
    width: 100%;
  } */
  /*Create vertical spacing*/
  li {
    margin-bottom: 1px;
  }
  /*Make all menu links full width*/
  ul li,
  li a {
    width: 100%;
  }
  /*Display 'show menu' link*/
  .show-menu {
    display: block;
  }
}

#main {
  height: 100%;
  padding-top: 1%;
  position: relative;
  width: 75%;
}

#imagehead {
  height: 45%;
  width: 100%;
}

.imagemask {
  display: block;
  max-width: 280px;
  right: 0;
  height: 180px;
  padding: 5px;
  overflow: hidden;
}

img {
  margin-left: auto;
  margin-right: auto;
}

.element {
  border: 2% #85e2ff;
  border-radius: 2%;
}
<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/patientprofile.css">
  <meta name="theme-color" content="#ffffff">
  <link href='https://fonts.googleapis.com/css?family=Barlow Semi Condensed' rel='stylesheet'>
</head>

<body>

  <div id="sidenav">
    <label for="show-menu" class="show-menu">Show My Information</label>
    <input type="checkbox" id="show-menu" role="button">
    <ul id="menu">
      <li><a href=#>My Health</a>
        <ul class="hidden">
          <li><a href=#>My Appointments</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
          <li><a href=#>My Results</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
          <li><a href=#>My Scans</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href=#>My Providers</a>
        <ul class="hidden">
          <li><a href=#>Dr. Dolittle</a></li>
          <li><a href=#>Ms. Shelly Sheldon</a></li>
          <li><a href=#>Mr. Titus Anromidon</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <div id="main">
    <div id="imagehead">
      <img class="imagemask" src="images/profile.jpg">
    </div>
  </div>


</body>

</html>

Ответы [ 2 ]

0 голосов
/ 26 июня 2018

Надеюсь, что это поможет, и надеюсь, что мое предположение верно в отношении того, чего вы пытаетесь достичь.

* {
  box-sizing: border-box;
  font-family: "Istok Web", "Barlow Semi Condensed", Arial, Helvetica, sans-serif;
  padding: 0;
  margin: 0;
}

/*12 col style for responsive page

#col-1 {
  width: 8.33%;
}

#col-2 {
  width: 16.66%;
}

#col-3 {
  width: 25%;
}

#col-4 {
  width: 33.33%;
}

#col-5 {
  width: 41.66%;
}

#col-6 {
  width: 50%;
}

#col-7 {
  width: 58.33%;
}

#col-8 {
  width: 66.66%;
}

#col-9 {
  width: 75%;
}

#col-10 {
  width: 83.33%;
}

#col-11 {
  width: 91.66%;
}

#col-12 {
  width: 100%;
}

[id*="col-"] {
  float: left;
} */

/* Fixed sidenav, full height */

#sidenav {
  width: 25%;
  height: 100%;
  position: fixed;
  z-index: 1;
  left: 0;
  overflow-x: hidden;
  padding-top: 17%;
}




/*Strip the ul of padding and list styling*/

ul {
  list-style-type: none;
  margin: 0;
  padding: 2%;
}

/*Create a horizontal list with spacing*/

li {
  display: block;
  margin-right: 1px;
}

/*Style for menu links*/

li a {
  display: block;
  height: 50px;
  text-align: center;
  line-height: 50px;
  color: #fc9497;
  text-decoration: none;
}

/*Style for dropdown links*/

li:hover ul a {
  color: #85e2ff;
  height: 40px;
  line-height: 40px;
}

/*Hover state for dropdown links*/

li:hover ul a:hover {
  color: #00BDF8;
}

/*Hide dropdown links until they are needed*/

li ul {
  display: none;
}

/*Make dropdown links vertical*/
li ul li {
  display: block;
  float: none;
}

/*Prevent text wrapping*/

li ul li a {
  width: auto;
  min-width: 100px;
  padding: 0 20px;
}

/*Display the dropdown on hover*/

ul li a:hover+.hidden,
.hidden:hover {
  display: block;
}

/*Style 'show menu' label button and hide it by default*/

.show-menu {
  text-decoration: none;
  color: #85e2ff;
  text-align: center;
  display: none;
}

/*Hide checkbox*/

input[type=checkbox] {
  display: none;
}

/*Show menu when invisible checkbox is checked*/

input[type=checkbox]:checked~#menu {
  display: block !important;
}

#main {
  height: 150vh;  /** just to make it scrollable. can be removed */
  min-height: 100vh;
  padding-top: 1%;
  position: relative;
  width: 100%;
  padding: 16px 16px 16px calc(25% + 16px);
}

#imagehead {
  height: 45%;
  width: 100%;
}

.imagemask {
  display: block;
  max-width: 280px;
  right: 0;
  height: 180px;
  padding: 5px;
  overflow: hidden;
}

img {
  margin-left: auto;
  margin-right: auto;
}

.element {
  border: 2% #85e2ff;
  border-radius: 2%;
}


/*Responsive Styles*/
@media screen and (max-width: 760px) {
    #sidenav {
      width:100%;
      left:0;
      top: 0;
      right: 0;
      height: auto;
      min-height: 60px;
      padding-top: 16px;
      background-color: #fff;
    }

    #main {
       padding-left: 16px;
       padding-top: 60px;
    }

   /*Make dropdown links appear inline*/
  ul#menu {
    display:none;
  }

  /*Remove col-3 width for total page width
  #col-3 {
    width: 100%;
  } */


  /*Create vertical spacing*/
  li {
    margin-bottom: 1px;
  }
  /*Make all menu links full width*/
  ul li,
  li a {
    width: 100%;
  }
  /*Display 'show menu' link*/
  .show-menu {
    display: block;
  }
}
<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/patientprofile.css">
  <meta name="theme-color" content="#ffffff">
  <link href='https://fonts.googleapis.com/css?family=Barlow Semi Condensed' rel='stylesheet'>
</head>

<body>

  <div id="sidenav">
    <label for="show-menu" class="show-menu">Show My Information</label>
    <input type="checkbox" id="show-menu" role="button">
    <ul id="menu">
      <li><a href=#>My Health</a>
        <ul class="hidden">
          <li><a href=#>My Appointments</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
          <li><a href=#>My Results</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
          <li><a href=#>My Scans</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href=#>My Providers</a>
        <ul class="hidden">
          <li><a href=#>Dr. Dolittle</a></li>
          <li><a href=#>Ms. Shelly Sheldon</a></li>
          <li><a href=#>Mr. Titus Anromidon</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <div id="main">
    <div id="imagehead">
      <h1>Profile</h1>
      <hr>
      <p>
         Lorem ipsum dolor sit amet, pri ea melius eligendi quaestio. Eam ludus 
         commune no, eu est percipit philosophia, ne has quando ullamcorper. Mel    
         euismod persequeris eu, eam in duis iusto concludaturque, postea efficiendi                           
         qui at. Nam te noster option efficiendi. Dicam apeirian scribentur ad pri. 
       </p>
      <p>
         Lorem ipsum dolor sit amet, pri ea melius eligendi quaestio. Eam ludus 
         commune no, eu est percipit philosophia, ne has quando ullamcorper. Mel    
         euismod persequeris eu, eam in duis iusto concludaturque, postea efficiendi                           
         qui at. Nam te noster option efficiendi. Dicam apeirian scribentur ad pri. 
       </p>
      <p>
         Lorem ipsum dolor sit amet, pri ea melius eligendi quaestio. Eam ludus 
         commune no, eu est percipit philosophia, ne has quando ullamcorper. Mel    
         euismod persequeris eu, eam in duis iusto concludaturque, postea efficiendi                           
         qui at. Nam te noster option efficiendi. Dicam apeirian scribentur ad pri. 
       </p>
      <p>
         Lorem ipsum dolor sit amet, pri ea melius eligendi quaestio. Eam ludus 
         commune no, eu est percipit philosophia, ne has quando ullamcorper. Mel    
         euismod persequeris eu, eam in duis iusto concludaturque, postea efficiendi                           
         qui at. Nam te noster option efficiendi. Dicam apeirian scribentur ad pri. 
       </p>
    </div>
  </div>


</body>

</html>
0 голосов
/ 26 июня 2018

Обновил ваш код ниже. Надеюсь, это работает для вас:)

* {
  box-sizing: border-box;
  font-family: "Istok Web", "Barlow Semi Condensed", Arial, Helvetica, sans-serif;
}

/*12 col style for responsive page

#col-1 {
  width: 8.33%;
}

#col-2 {
  width: 16.66%;
}

#col-3 {
  width: 25%;
}

#col-4 {
  width: 33.33%;
}

#col-5 {
  width: 41.66%;
}

#col-6 {
  width: 50%;
}

#col-7 {
  width: 58.33%;
}

#col-8 {
  width: 66.66%;
}

#col-9 {
  width: 75%;
}

#col-10 {
  width: 83.33%;
}

#col-11 {
  width: 91.66%;
}

#col-12 {
  width: 100%;
}

[id*="col-"] {
  float: left;
} */

/* Fixed sidenav, full height */

#sidenav {
  width: 25%;
  height: 100%;
  position: fixed;
  z-index: 1;
  left: 0;
  overflow-x: hidden;
  padding-top: 10%;
  background: #fff;
}

/*Strip the ul of padding and list styling*/

ul {
  list-style-type: none;
  margin: 0;
  padding: 2%;
}

/*Create a horizontal list with spacing*/

li {
  display: block;
  margin-right: 1px;
}

/*Style for menu links*/

li a {
  display: block;
  height: 50px;
  text-align: center;
  line-height: 50px;
  color: #fc9497;
  text-decoration: none;
}

/*Style for dropdown links*/

li:hover ul a {
  color: #85e2ff;
  height: 40px;
  line-height: 40px;
}

/*Hover state for dropdown links*/

li:hover ul a:hover {
  color: #00BDF8;
}

/*Hide dropdown links until they are needed*/

li ul {
  display: none;
}

/*Make dropdown links vertical*/

li ul li {
  display: block;
  float: none;
}

/*Prevent text wrapping*/

li ul li a {
  width: auto;
  min-width: 100px;
  padding: 0 20px;
}

/*Display the dropdown on hover*/

ul li a:hover+.hidden,
.hidden:hover {
  display: block;
}

/*Style 'show menu' label button and hide it by default*/

.show-menu {
  text-decoration: none;
  color: #85e2ff;
  text-align: center;
  padding: 10px 0;
  display: none;
  float: left;
}

/*Hide checkbox*/

input[type=checkbox] {
  display: none;
}

/*Show menu when invisible checkbox is checked*/

input[type=checkbox]:checked~#menu {
  display: block;
}

/*Responsive Styles*/

@media screen and (max-width: 760px) {
  /*Make dropdown links appear inline*/
  ul {
    position: fixed;
    top: 0;
    width: 100%;
    display: none;
    padding-top: 20px;
    float: left;
  }
  /*Remove col-3 width for total page width
  #col-3 {
    width: 100%;
  } */
  /*Create vertical spacing*/
  li {
    margin-bottom: 1px;
  }
  /*Make all menu links full width*/
  ul li,
  li a {
    width: 100%;
  }
  /*Display 'show menu' link*/
  .show-menu {
    display: block;
  }
}

#main {
  height: 100%;
  padding-top: 1%;
  position: relative;
  width: 75%;
  float: right;
}

#imagehead {
  height: 45%;
  width: 100%;
}

.imagemask {
  display: block;
  max-width: 280px;
  right: 0;
  height: 180px;
  padding: 5px;
  overflow: hidden;
}

img {
  margin-left: auto;
  margin-right: auto;
}

.element {
  border: 2% #85e2ff;
  border-radius: 2%;
}
<div id="sidenav">
    <label for="show-menu" class="show-menu">Show My Information</label>
    <input type="checkbox" id="show-menu" role="button">
    <ul id="menu">
      <li><a href=#>My Health</a>
        <ul class="hidden">
          <li><a href=#>My Appointments</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
          <li><a href=#>My Results</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
          <li><a href=#>My Scans</a>
            <ul class="hidden">
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
              <li><a href=#>##/##/##</a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href=#>My Providers</a>
        <ul class="hidden">
          <li><a href=#>Dr. Dolittle</a></li>
          <li><a href=#>Ms. Shelly Sheldon</a></li>
          <li><a href=#>Mr. Titus Anromidon</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <div id="main">
    <div id="imagehead">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </div>
...