Мой сайт не отвечает на запросы СМИ - PullRequest
0 голосов
/ 17 марта 2019

Я новичок в веб-разработке, и у меня есть небольшой веб-сайт с 3 страницами.Моя цель - использовать теги @media, чтобы они отвечали следующим требованиям: max-width s: 980px, 768px и 640px.Я сделал первую страницу, и она ведет себя странно.Как я могу сделать весь сайт адаптивным?Пожалуйста, чтобы помочь.Мой код для всех 3 страниц и СМИ прилагается.Спасибо.

/*first page */
     <head>
        	<title>AboutMe</title>
        	<link rel="stylesheet" type="text/css" href="assets/css/style.css">
        	<meta name="viewport" content="width=device-width, initial-scale=1">
        </head>
        <body>	
        	<div class="container">
        			<div class="top">
        				<div class="myname">
        					<h4 class="firstlast">name</h4>
        				</div>
        				<div class="list">
        					<ul>
        						<li class="contact"><a href="contact.html">Contact</a></li>
        						<li class="portfolio"><a href="portfolio.html">Portfolio</a></li>
        						<li class="about">About</li>
        					</ul>
        				</div>
        			</div>
        
        			<div class="middle-about-me"> 
        				<div class="center">
        					<h3>&emsp;About Me</h3>
        					<hr>
        					<p class="myinfo">Hi my name is ..... and I was born on October 9th, 1971 in ......
        						<img src="assets/img/author.jpg" width="150px" height="150px"><br>
        						&thinsp;&thinsp;To briefly introduce the... to you I would say it is a country located on the........>
        						&thinsp;&thinsp;&thinsp;&thinsp;shares the same borders with ....... It is the world largest<br> 
        						&emsp;producer of coacoa used for chocalate and lotions. In one word, it's the country where chocolate tastes like<br> &emsp;real chocolate. Since the last discovery of petrol in the country, it's been a little agitated as France and the<br>US want to control the discovery. After obtaining my masters in Business Management, I worked as the marketing representative for an american company before moving to the US to pursue a degree in Mathematic at UNT Dallas and worked for...,...., and.... as a Math instructor. My goal in this program is to learn to build websites from scratch and later on to build apps from scratch. I've got the right instructional staff and the right TAs to help me reach that goal. All I have to do is to go to work.<br> &emsp;&emsp;"Impossible is nothing",  Muhammad Ali.</p>
              <p class="smile"><i>hover on my picture and start smiling</i></p>
        				</div>
        			</div>
        			<div class="footer">
        				<p class="footer-copyright">Copyrigtht &copy; 2019 Portfolio "name" All rights reserved.</p>
        		
        			</div>
        	</div>
        
        </body>
    
    
    
        /*second page */
        <body>	
        	<div class="container">
        			<div class="top">
        				<div class="myname">
        					<h4 class="firstlast">name</h4>
        				</div>
        				<div class="list">
        					<ul>
        						<li><a href="contact.html">Contact</a></li>
        						<li>Portfolio</li>
        						<li><a href="index.html">About Me</a></li>
        					</ul>
        				</div>		
        			</div>
        
        			<div class="middle">
        				<div class="center-portfolio">
        					<h3>&emsp;Portfolio</h3>
        					<hr>
        					<div class="div1"><img src="assets/img/career1.jpg" height="120px" width="150px"></div>
        					<div class="div2"><img src="assets/img/chocolatour.jpg" height="120px" width="150px"></div>
        					<div class="div3"><img src="assets/img/guildhouse.jpg" height="120px" width="150px"></div>
        					<div class="div4"><img src="assets/img/career2.jpg" height="120px" width="150px"></div>
        					<div class="rotateIn div5"><img src="assets/img/Abidjan1.jpg" height="120px" width="150px"></div>
        					<div class="div6"><p><i>please to hover on the images</i></p></div>
        					<div class="banner1">career picture 1</div>
        					<div class="banner2">chocolate tour</div>
        					<div class="zoomIn banner5">Abidjan</div>
        					<div class="banner4">career picture 2</div>
        					<div class="banner3">Guild Brussels</div>
        				</div>
        			</div>
        			<div class="footer">
        				<p class="footer-copyright"> Copyrigtht &copy; 2019 Portfolio "name" All rights reserved.</p>
        			</div>
        	</div>
        
        </body>
        
        
        /*third page */
        <body>	
        	<div class="container">
        			<div class="top">
        				<div class="myname">
        					<h4 class="firstlast">name</h4>
        				</div>
        				<div class="list">
        					<ul>
        						<li>Contact</li>
        						<li><a href="portfolio.html">Portfolio</a></li>
        						<li><a href="index.html">About Me</a></li>
        					</ul>
        				</div>
        			</div>
        
        			<div class="middle">
        				<div class="center">
        					<h3>&emsp;Contact</h3>
        					<hr>
        						<form>
        							&emsp;&thinsp;Name:<br>
        							<input id="namebox" type="text" name="name" required="" placeholder="your name">
        							<br><br>
        							&emsp;&thinsp;Email:<br>
        							<input id="emailbox" type="Email" name="email" required="" placeholder="example@yahoo.com">
        							<br><br>
        							&emsp;&thinsp;Message:<br>
        							<textarea id="messagebox" style="height: 200px; " name="message" placeholder="Enter massage here" required="">
        							</textarea>
        							<br><br>
        							&emsp;&thinsp;<input type="submit" value="submit" name="submit">
        						</form>
        						<br>
        				</div>
        			</div>
        			<div class="footer">
        				<p class="footer-copyright">
        					Copyrigtht &copy; 2019 Portfolio "name" All rights reserved.
        				</p>
        			</div>
        	</div>
        
        </body>
    
    
    
    /* Width at 768px and below */
    @media screen and (max-width: 768px) {
    
      body {
    		background-color : #E9967A;
      }
    
      .container {
      	background-color: green;
      	border-style: none;
        width: 50%;
      }
    
     .middle-about-me,
     .footer, .top{
      	width: 50%;
      }
    
      .middle-about-me{
        width: 50%%;
      }
    }
    
     /*Width at 640px and below */
    @media screen and (max-width: 640px) {
    
      body {
    		background-color : #E9967A;
      }
    
      .container {
      	background-color: green;
      	border-style: none;
        width: 50%;
      }
    
     .middle-about-me,
     .footer, .top{
      	width: 50%;
      }
    
      .middle-about-me{
        width: 50%%;
      }
    
    }

Ответы [ 2 ]

0 голосов
/ 17 марта 2019

Хотелось бы, чтобы у вас был эскиз того, как будет выглядеть конечный продукт, он был бы очень полезен. Это не просто сделать правильный HTML-тег и соответствующие стили и опечатки, потому что из вашего кода дополнительный знак % сделает

  .middle-about-me{
   width: 50%%;
  }

безобразничать. Есть пара вещей, которые нужно знать, чтобы сделать отзывчивость страницы эффективной и очень близкой к тому, что вы хотите. Во-первых, вам следует рассмотреть возможность сброса стилей по умолчанию, которые браузер естественным образом применяет к допустимым тегам HTML, с помощью normalize.css или использования универсального селектора, который почти так же хорош в современных браузерах, например:

*,
*::before,
*::after{
padding: 0;
margin: 0;
box-sizing: inherit; /* to inherit the value declared in the body selector */
}

html{
font-size: 62.5% /* (10/16) * 100%  and this is possible because by default the value of 100% will be computed to 16px by the browser and equal to 1(r)em, with this conversion we can reduce the calculations whenever you want to convert a value from px to (r)em since the are in multiples of 10 eg 1(r)em == 10px and 10(r)em == 100px*/
}

body{
box-sizing: border-box;
}

img{
width: 100%;
min-width: 27rem; /* to make the images responsive and look good on smaller screens */
}

так что с этим базовым сбросом вы всегда можете положиться на em s или rem s для шрифтов в процентах для изображений и других блочных элементов, когда это будет уместно. Эта небольшая статья недостаточно для того, чтобы научить вас всему, что нужно знать об отзывчивости в Интернете, но я надеюсь, что она проливает свет на ваш путь. Между тем это были не мои оригинальные идеи, которые я взял на курс «Йонаса Шмедтмана», он на самом деле думал, что я таков. Если у вас есть набросок того, как должны выглядеть последние страницы, или вы все еще не очень понимаете, что я пытался объяснить до сих пор, пожалуйста, не стесняйтесь добавлять комментарии, чтобы мы приводили их в порядок.

0 голосов
/ 17 марта 2019

Начните с удаления фиксированных width свойств. Мне трудно видеть, как тебе нужно width: 50% на все. Затем начните с рассмотрения стилей элемента .container.

Хорошим приемом является установка max-width на ширину, которую вы имеете в виду, чтобы сайт просматривался на обычном экране рабочего стола, в демонстрационной программе, которую я использовал 600px, но вы можете использовать любое подходящее значение.

Затем в вашем медиа-запросе назначьте новое значение max-width, соответствующее размеру экрана в запросе, здесь я использовал 80%, потому что обычно на маленьких экранах вы хотите, чтобы контент в основном занимал всю ширину экрана немного места по бокам, но опять же вы можете настроить его в соответствии со своими потребностями различными способами.

Главное здесь - это то, что ваш контейнерный элемент теперь отзывчив, и содержимое внутри может заполнять пространство, как вам нравится. Запустите фрагмент и нажмите на ссылку «Полная страница», чтобы поэкспериментировать с шириной экрана и увидеть, как оно работает.

.container {
  max-width: 600px;
  margin: 0 auto;
}

@media screen and (max-width: 640px;) {
  .container {
    max-width: 80%;  
  }
}
<div class="container">
  <div class="top">
    <div class="myname">
      <h4 class="firstlast">name</h4>
    </div>
    <div class="list">
      <ul>
        <li class="contact"><a href="contact.html">Contact</a></li>
        <li class="portfolio"><a href="portfolio.html">Portfolio</a></li>
        <li class="about">About</li>
      </ul>
    </div>
  </div>
  <div class="middle-about-me"> 
    <div class="center">
      <h3>&emsp;About Me</h3>
      <hr>
      <p class="myinfo">Hi my name is ..... and I was born on October 9th, 1971 in ......
        <img src="assets/img/author.jpg" width="150px" height="150px"><br>
                            &thinsp;&thinsp;To briefly introduce the... to you I would say it is a country located on the........>
                            &thinsp;&thinsp;&thinsp;&thinsp;shares the same borders with ....... It is the world largest<br> 
                            &emsp;producer of coacoa used for chocalate and lotions. In one word, it's the country where chocolate tastes like<br> &emsp;real chocolate. Since the last discovery of petrol in the country, it's been a little agitated as France and the<br>US want to control the discovery. After obtaining my masters in Business Management, I worked as the marketing representative for an american company before moving to the US to pursue a degree in Mathematic at UNT Dallas and worked for...,...., and.... as a Math instructor. My goal in this program is to learn to build websites from scratch and later on to build apps from scratch. I've got the right instructional staff and the right TAs to help me reach that goal. All I have to do is to go to work.<br> &emsp;&emsp;"Impossible is nothing",  Muhammad Ali.</p>
          <p class="smile"><i>hover on my picture and start smiling</i></p>
        </div>
      </div>
      <div class="footer">
        <p class="footer-copyright">Copyrigtht &copy; 2019 Portfolio "name" All rights reserved.</p>
    </div>
</div>
...