Контент не центрирован, как ожидалось, с медиа-запросами - PullRequest
0 голосов
/ 27 июня 2018

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

Ссылка на сайт здесь http://moeminmamdouh.000webhostapp.com/aboutme.html

Желаемый результат состоит в том, чтобы в основном все было в центре, однако, это то, что показывает https://ibb.co/idEPVT

ЗДЕСЬ КОДЕННАЯ ССЫЛКА: https://codepen.io/muchkler/project/editor/AznjbN#

Это HTML-код:

<!DOCTYPE html>
<html>
<head> 
    <title> About Me </title>
    <link rel="stylesheet" type="text/css" href="aboutme.css">
    <link rel="stylesheet" type="text/css" href="bootstrap.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,600,700" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans:400,700" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="icon" href="apple-icon.png">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="index.html">Moemin Mamdouh</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="portfolio.html">Portfolio <span class="sr-only">(current)</span></a></li>
        <li class="active"><a href="#">About Me</a></li>
          <li><a href="#">Contact Me</a></li>
          </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

    <img src="images/rightprof.png" class="rightprof">

<div class="row">    
   <h1>HELLO.</h1>
    <h2>I'm Moemin Mamdouh</h2>
    <h3>graphic designer/ ui designer/ front-end developer</h3>
    <p>I provide entrepeneurs and startups with the kick they need to help start their business. A business is nothing without a brand, and a brand requires a stable and responsive website. I will be providing designs in both Adobe Photoshop and Adobe XD as the first step to any projects, afterwards, I move on to coding the actual website using HTML, CSS, and Bootstrap.  </p>
    <div class="imgbtns">
    <a href="https://www.facebook.com/moemin.mamdouh.3"><img src="images/facebook.png" height="30px" width="30px" class="facebook"></a>
    <a href="https://www.behance.net/Muchkler"><img src="images/behance.png" height="30px" width="30px" class="behance">  </a>  
</div>   
</div>   



</body>
</html>

и это код CSS:

body{
    background: url(images/tom-sini-710353-unsplash.jpg);
    background-position: center;
    background-attachment: fixed;
    background-size: cover; 
    background-repeat: no-repeat; 
    height: 100%; 


}



.row{
    color: white; 
    padding-top: 350px;
    padding-left: 250px;
    width: 900px;

}

.rightprof{
    float: right; 
    padding-top: 250px;
    padding-right: 250px;
}

.navbar-default{
    background-color: #D91E18 !important;
    border-style: none !important; 
}

.navbar-brand{
    color: white !important; 
}

.navbar-default .navbar-nav > li > a {
  color: white !important; 
}

.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
  color: #555;
  background-color: #CF000F !important;
}

@media only screen and (max-width: 992px){
    .leftside{
        padding: 300px; 
    }


}



@media only screen and (max-width: 992px){
    .row{
        text-align: center; 
        padding-right: 110px;

    }

    .rightprof{

    }

}

@media only screen and (max-width: 1042px){

    .row{
        text-align: center; 


}

@media only screen and (max-width: 768px){

    .row{
    font-size: 10px;
    width: auto;
    margin-right: 200px; 
    }


    }

любая помощь будет оценена, спасибо!

1 Ответ

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

Я предлагаю удалить ваш файл about.css. Изучите сетку. В вашем коде отсутствовал «.container» вокруг вашего «.row», а у вас отсутствовало определение столбца (.col-sm-8, .col-sm-4). Избегайте добавления CSS ширины и плавания к вашим изображениям и контенту, так как это взорвет адаптивную сетку. Вместо этого добавьте к изображениям класс «.img-отзывчивый».

<!doctype html>
<html>

<head>
    <title> About Me </title>

    <link rel="stylesheet" type="text/css" href="bootstrap.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,600,700" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans:400,700" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
        crossorigin="anonymous">
    <link rel="icon" href="apple-icon.png">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
</head>

<body style="padding-top:70px;">
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
                    aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index.html">Moemin Mamdouh</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li>
                        <a href="portfolio.html">Portfolio
                            <span class="sr-only">(current)</span>
                        </a>
                    </li>
                    <li class="active">
                        <a href="#">About Me</a>
                    </li>
                    <li>
                        <a href="#">Contact Me</a>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>



    <div class="container">
        <div class="row">
            <div class="col-sm-8">
                <h1>HELLO.</h1>
                <h2>I'm Moemin Mamdouh</h2>
                <h3>graphic designer/ ui designer/ front-end developer</h3>
                <p>I provide entrepeneurs and startups with the kick they need to help start their business. A business is nothing
                    without a brand, and a brand requires a stable and responsive website. I will be providing designs in
                    both Adobe Photoshop and Adobe XD as the first step to any projects, afterwards, I move on to coding
                    the actual website using HTML, CSS, and Bootstrap. </p>
                <div class="imgbtns">
                    <a href="https://www.facebook.com/moemin.mamdouh.3">
                        <img src="images/facebook.png" height="30px" width="30px" class="facebook">
                    </a>
                    <a href="https://www.behance.net/Muchkler">
                        <img src="images/behance.png" height="30px" width="30px" class="behance"> </a>
                </div>
            </div>
            <div class="col-sm-4">
                <img src="images/rightprof.png" class="img-responsive">
            </div>
        </div>
    </div>
</body>
</html>
...