• Najnowsze pytania
  • Bez odpowiedzi
  • Zadaj pytanie
  • Kategorie
  • Tagi
  • Zdobyte punkty
  • Ekipa ninja
  • IRC
  • FAQ
  • Regulamin
  • Książki warte uwagi

Dodatkowy margines w wersji mobilnej strony

0 głosów
3,274,217 wizyt
pytanie zadane 10 maja 2020 w HTML i CSS przez Depus7 Nowicjusz (160 p.)

  Witam 

Mam problem z tworzeniem strony www do wersji responsywnej za pomocą @media a mianowicie gdy sprawdzam jak moja strona wygląda w wersji responsywnej pojawia się dodatkowy margines na urządzeniach mobilnych , który wygląda w sposób następujący. Zaznaczony na kolor czerwony   https://tinypic.pl/jvhqjh3c16mr

Być może problem jest w headerze ponieważ on tam mocno wystaje natomiast gdy pozbyłem się wystającego headera to i tak ów margines nadal był. Poniżej zamieszczam kod do headera. 

 <header class="clearfix">
        <nav>
            <p>Lorem</p>
            <ul class="clearfix">
                <li class="list"><a href=""><i class="fas fa-male"></i> O mnie</a></li>
                <li class="list"><a href=""><i class="fas fa-dolly-flatbed"></i>Nasza oferta</a></li>
                <li class="list"><a href=""><i class="fas fa-atlas"></i>Doświadczenie</a></li>
                <li class="list"><a href=""><i class="far fa-envelope"></i>Kontakt</a></li>
            </ul>
        </nav>
    </header>
body {
    font-family: 'Lato', sans-serif;
}

.clearfix::after {
    content: '';
    display: block;
    clear: both;
}

nav {
    position: fixed;
    width: 100%;
    z-index: 999;
    max-width: 100%;
}

nav p {
    text-transform: uppercase;
    vertical-align: 20px;
    float: left;
    padding: 1%;
    max-width: 80%;
}


ul {
    background-color: rgba(160, 202, 209, 0.93);
    list-style-type: none;
    max-width: 100%;
}

li {
    padding: 1%;
    float: right;
}


header {
    background-image: url(grafika/background.6.jpg);
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    height: 100vh;
    max-width: 100%;

z góry dziękuję za pomoc :)  

komentarz 10 maja 2020 przez Piotr Młynarczyk Początkujący (380 p.)
edycja 10 maja 2020 przez Piotr Młynarczyk

@Depus7,  Na podstawie tego kodu, który udostępniłeś nie mogę zobaczyć marginesu w treści strony. Widzę tylko heder.

Po dodaniu dva'a w czarnym kolorze widzę w chrome marginesy po prawej i lewej stronie.

Heder też ma margines po lewej stronie. Prawdopodobnie jest to standardowy margines body w chrome. Na tablecie jest to samo też w chrome..

1 odpowiedź

0 głosów
odpowiedź 11 maja 2020 przez Depus7 Nowicjusz (160 p.)

W sumie może lepiej udostępnie cały kod 

<html lang="pl">

<head>
    <meta charset="UTF-8">
    <title>Lorem</title>
    <link rel="stylesheet" href="style.css">
    <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,400&display=swap" rel="stylesheet">
    <link href="C:\Users\dawid\OneDrive\Pulpit\strona www\fontawesome-free-5.13.0-web\css/all.css" rel="stylesheet">
    <meta name="viewport" content="width=device-width,  initial-scale=1.0, ">
</head>

<body>
    <div id="container">
    <header class="clearfix">
        <nav>
            <p><a href="#">Lorem</a></p>
            <ul class="clearfix">
                <li class="list"><a href="#Lorem"><i class="fas fa-male"></i> Lorem</a></li>
                <li class="list"><a href="#Lorem"><i class="fas fa-dolly-flatbed"></i>Lorem</a></li>
                <li class="list"><a href="#Lorem"><i class="fas fa-atlas"></i>Lorem</a></li>
                <li class="list"><a href="#Lorem"><i class="far fa-envelope"></i>Lorem</a></li>
            </ul>
        </nav>
    </header>
        <main class="main">
            <article id="abouth">
                <section id="discription">
                    <h2 > O mnie</h2>
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic consectetur repellendus dignissimos veritatis alias quidem, nobis in distinctio, cum reiciendis impedit eveniet voluptatem animi ratione, esse explicabo rerum dicta at?</p>
                </section>
                <section id="story">
                    <h2 id="Lorem">Lorem</h2>
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat harum maiores necessitatibus eum neque inventore quo cumque reprehenderit provident voluptas quos dolore, esse enim, eos ducimus veniam eligendi! Deleniti, provident.</p>
                </section>
            </article>
            <div id="freetime">
                <h2 >Lorem</h2>
            </div>
            <section id="photos clearfix">
                <div class="photo">
                    <p>Lorem</p>
                </div>
                <div class="photo">
                    <p>LOREM</p>
                </div>
                <div class="photo">
                    <p>lLorem</p>
                </div>
                <div class="photo">
                    <p>Lorem</p>
                </div>
            </section>
            <article id="experience">
                <div class="belt">
                    <h1 id="Lorem">Lorem</h1>
                </div>
                <section id="mainexperience">
                    <div class="clearfix clear">
                        <div class="text">
                            <i class="fas fa-chart-line"></i>
                            <h2>Lorem</h2>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui vero dolores quibusdam quod, beatae quos, natus dolorem voluptatum voluptate cupiditate architecto dicta veritatis exercitationem facilis iste, adipisci deserunt quis unde.</p>
                        </div>
                        <div class="text">
                            <i class="fas fa-search-dollar"></i>
                            <h2>Lorem</h2>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia quisquam, eius. Vitae explicabo dolorem aperiam, cupiditate omnis? Asperiores nulla omnis quae quasi in neque id quia, sint, eos, hic rem.</p>
                        </div>
                        <div class="text">
                            <i class="fas fa-people-carry"></i>
                            <h2>Lorem</h2>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eaque optio enim officiis accusamus tempora, iure explicabo, nemo labore laudantium voluptate, fuga cumque quam, rerum adipisci voluptas! Pariatur alias quasi voluptatum.</p>
                        </div>
                    </div>
                </section>
            </article>
            <h2 id="oferta">Lorem</h2>
            <article id="offer">
                <section class="oneoffer">
                    <div class="clear1 clearfix">
                        <div class="stand">
                            <div class="icon1"><img src="icons/icon1.png" alt="icon1"></div>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At optio impedit voluptate repellat vitae iusto, rerum perspiciatis sunt debitis dolor, numquam eum quibusdam velit placeat pariatur alias. Deleniti, soluta, perspiciatis.</p>
                        </div>
                        <div class="stand">
                            <div class="icon1"><img src="icons/icon2.png" alt="icon2"></div>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At optio impedit voluptate repellat vitae iusto, rerum perspiciatis sunt debitis dolor, numquam eum quibusdam velit placeat pariatur alias. Deleniti, soluta, perspiciatis.</p>
                        </div>
                        <div class="stand">
                            <div class="icon1"><img src="icons/icon3.png" alt="icon3"></div>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At optio impedit voluptate repellat vitae iusto, rerum perspiciatis sunt debitis dolor, numquam eum quibusdam velit placeat pariatur alias. Deleniti, soluta, perspiciatis.</p>
                        </div>
                    </div>
                </section>
                <section class="clearfix sekendoffer">
                    <div class="clear1 clearfix">
                        <div class="stand2">
                            <div class="icon1"> <img src="icons/icon4.png" alt="icon4"></div>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At optio impedit voluptate repellat vitae iusto, rerum perspiciatis sunt debitis dolor, numquam eum quibusdam velit placeat pariatur alias. Deleniti, soluta, perspiciatis.</p>
                        </div>
                        <div class="stand2">
                            <div class="icon1"> <img src="icons/icon5.png" alt="icon5"></div>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. At optio impedit voluptate repellat vitae iusto, rerum perspiciatis sunt debitis dolor, numquam eum quibusdam velit placeat pariatur alias. Deleniti, soluta, perspiciatis.</p>
                        </div>
                        <div class="stand2">
                            <div class="icon1"> <img src="icons/icon6.png" alt="icon6"></div>
                            <p id="kontakt">Lorem ipsum dolor sit amet, consectetur adipisicing elit. At optio impedit voluptate repellat vitae iusto, rerum perspiciatis sunt debitis dolor, numquam eum quibusdam velit placeat pariatur alias. Deleniti, soluta, perspiciatis.</p>
                        </div>
                    </div>
                </section>
            </article>
            <article class="contact">
                <h2>Lorem</h2>
                <div class="wrap clearfix">
                    <form>
                        <input type="text" placeholder="Twoje imię">
                        <input type="text" placeholder="Email">
                        <textarea placeholder="Twoja wiadomość"></textarea>
                        <button>Wyślij wiadomość</button>
                    </form>
                    <section class="socials">
                        <div class="social clearfix"><img src="grafika/contact1.png" alt="">
                            <p>email@domena.pl</p>
                        </div>
                        <div class="social clearfix"><img src="grafika/contact2.png" alt="">
                            <p>666 666 666 </p>
                        </div>

                        <div class="social clearfix"><img src="grafika/contact3.png" alt="">
                            <p>Lorem</p>
                        </div>
                        <div class="social clearfix"><img src="grafika/contact4.png" alt="">
                            <p>Lorem</p>
                        </div>

                        <div class="social clearfix"><img src="grafika/contact5.png" alt="">
                            <p>Lorem</p>
                        </div>
                    </section>
                </div>
            </article>

        </main>
        <footer> &copy;</footer>
    </div>

</body></html>

Wgl gdy badałem stronę np w mozilli to takowy margines się nie pojawiał 

komentarz 11 maja 2020 przez Depus7 Nowicjusz (160 p.)

tutaj jeszcze CSS ;)  

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}


body {
    font-family: 'Lato', sans-serif;
    max-width: 100vw;
}

.clearfix::after {
    content: '';
    display: block;
    clear: both;
}

nav {
    position: fixed;
    width: 100%;
    z-index: 999;
 
}

nav p {
    text-transform: uppercase;
    vertical-align: 20px;
    float: left;
    padding: 1%;
}

nav p a {
    color: black;
    text-decoration: none;
}

ul {
    background-color: rgba(160, 202, 209, 0.93);
    list-style-type: none;
    max-width: 100%;
}

li {
    padding: 1%;
    float: right;
}


header {
    background-image: url(grafika/background.6.jpg);
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    height: 100vh;
   

}

.main {
    min-height: 100vh;
}

ul li a {
    text-decoration: none;
    text-transform: uppercase;
    line-height: 30px;
    color: black;
    transition: 1s;
}

ul li a i {
    font-size: 24px;
    margin-right: 8px;
    padding-top: 3%;
    float: left;
}

/* Sekcja "O mnie */

#abouth
{
    position: relative;
    height: 100vh;
    background-image: url(grafika/1.png);
    background-position: bottom;
    background-repeat: no-repeat;
    background-size: cover;
}
#discription
{
    z-index: 1;
    position: absolute;
    top: 7%;
    left: 65%;
    padding: 1%;
    border: 5px solid black;
    border-radius: 5%;
    width: 27%;
    height: 40%;
}

#discription h2{
    font-size: 32px;
    border-bottom: 2px solid black;
}

#discription p
{
    padding-top: 4%;
    font-size: 24px;
    text-align: justify;
}

#story{
    position: absolute;
    top: 6.5%;
    left:5% ;
    font-size: 24px;
    text-align: justify;
    padding: 1%;
    border: 5px solid black;
    border-radius: 5%;
    width: 25%;
    height: 45%;
}

#story h2{
    font-size: 32px;
    border-bottom: 2px solid black;
}

#story p{
    padding-top: 4%;
}

/* Co robię w wolnym czasie*/ 

#freetime h2
{
    background-color: #5C5CE0;
    width: 100%;
    font-size: 42px;
    padding: 1% 0 1% 0;
    text-align: center;
    text-transform: uppercase;
}

#photos
{
    height: 120vh;
    overflow: hidden;
}

#photos .photo{
    float: left;
    overflow: hidden;
    background-size: 100%;
    transition: 3s;
    width: 50%;
    height: 30vh;
}

.photo p{
    opacity: 0;
    font-size: 20px;
    text-transform: uppercase;
    color: white;
    text-align: center;
    line-height: 50vh;
    background-color: rgba(0, 0, 0, .5);
    font-size: 24px;
    transition: 1s;
    overflow: hidden;
}



.photo:nth-of-type(1){
    background-image: url(grafika/travel2.jpg);
    transition: 3s;
    float: left;
    overflow: hidden;
    background-position: bottom;
    background-repeat: repeat;
    background-size: cover;
    width: 50%;
    height: 50vh;
}


.photo:nth-of-type(2){
    background-image: url(grafika/cooking2.jpg);
    overflow: hidden;
    background-position: center;
    transition:3s;
    background-repeat: repeat;
    background-size: cover;
    height: 50vh;
}

.photo:nth-of-type(3){
    background-image: url(grafika/zmiana1.jpg);
    background-position: center;
    transition:3s;
    background-repeat: repeat;
    background-size: cover;
    float: left;
    width: 50%;
    height: 50vh;
}

.photo:nth-of-type(4){
    background-image: url(grafika/czytanie1.jpg);
    background-position: center;
    transition: 3s;
    background-repeat: repeat;
    background-size: cover;
    height: 50vh;
}

/*experience-Doświadczenie*/

#experience{
    background-color: white;
    min-height: 150vh;
}

.belt{
    height: 40vh;
    background-image: url(grafika/background.5.jpg);
    background-attachment: fixed;
    background-color: rgba(0, 0, 0, .6);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

#experience h1{
    text-align: center;
    text-shadow: 5%;
    text-transform: uppercase;
    font-size: 36px;
    color: white;
    margin-top: 5%;
    padding: 1% 0 1% 0;
    width: 100%;
    line-height: 36vh;
    height: 40vh;
    background-color: rgba(0, 0, 0, .5);
}

#mainexperience{
    width: 100%;
    height: 150vh;
    margin-top: 10%;
    background-image: url(grafika/smart.jpg);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

.text h2{
    text-transform: uppercase;
    font-size: 32px;
    margin-bottom: 1.5%;
    padding-bottom: 2%;
}

.text{
    margin-left: 9.5%;
    width: 20%;
    float: left;
    color: white;
    transition: 2s;
    background-color: rgba(3, 1, 1, 0.58);
    padding: 2%;
    text-transform: uppercase;
    font-size: 24px;
    margin-top: 5%;
}

.text p{
    text-align: center;
    padding-top: 3.5%;
    border-top: 3px solid black;
    transition: 2s;
}

.text i
{
    font-size: 56px;
    width: 100%;
    transition: 2s;
    text-align: center;
    padding-bottom: 5%;
}

/*Nasza oferta- our offer*/

#offer{
   background-image: url(grafika/tloofert.3.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    margin-top: 5%;
    width: 100%;
    min-height: 100vh;
}

#oferta{
    color: white;
    text-align: center;
    text-transform: uppercase;
    background-image: url(grafika/grucha.jpg);
    background-repeat: no-repeat;
    background-position: bottom;
    background-size: cover;
    background-attachment: fixed;
    margin-bottom: 5%;
    margin-top: 5%;
    font-size: 32px;
    font-weight: 800;
    line-height: 30vh;
    height: 30vh;
    width: 100%;
}

.oneoffer{
    padding: 5% 0 0 10%;
    width: 100%;
    text-align: center;
}

.stand{
    position: relative;
    margin-top: 3%;
    margin-right: 5%;
    background-color: #00c4ff;;
    text-align: center;
    float: left;
    height: 30vh;
    width: 25%;
}
.stand p{
    padding-top: 25%;
}

.icon1{
    position: absolute;
    top: 6%;
    left: 38%;
}

.sekendoffer{
    padding: 5% 0 0 10%;
    width: 100%;
    height: 69vh;
    text-align: center;
}

.stand2{
    position: relative;
    margin-right: 5%;
    background-color: deepskyblue;
    text-align: center;
    float: left;
    height: 30vh;
    width: 25%;
}

.stand2 p{
    padding-top: 25%;
}

/*Contact- kontakt*/


.contact{
    color: white;
    background-color: black;
}

.contact h2 {
    font-size: 60px;
    text-align: center;
    text-transform: uppercase;
    padding: 2% 0 2% 5%;
  }
  .contact form,
  .contact .socials {
    float: left;
    width: 50%;
    padding: 0 5%;
  }

  .contact .social {
    width: 50%;
    margin: 0 auto;
    margin-bottom: 5%;
}

  .contact input,
  .contact button,
  .contact textarea {
    margin-bottom: 4%;

  }
  .contact input {

    height: 8vh;
      width: 100%;
    font-size: 24px;

  }

  .contact textarea {
    height: 22vh;
    font-size: 24px;
      width: 100%;
  }

  .contact button {
    padding: 2%;
      color: white;
    background-color: black;
    text-transform: uppercase;
    font-size: 20px;
    line-height: 50px;
    transition: 0.5s;
    cursor: pointer;
    border: 3px solid white;
  }
  
.social img
{
    float: left;
}

.social p{
padding-top: 9%;
padding-left: 27%;
}

/*Footer*/
footer
{
    background-color: rgb(160, 202, 209);
    max-height: 10%;
    text-align: center;
    text-transform: uppercase;
    padding-bottom: 0.5%;
    padding-top: 0.5%;
}



/* Hover na desptop od 1024px */

@media (min-width:1024px){
    .list a:hover{
        color: white;
    }
    .photo:hover p{
    opacity: 1;
}

.photo:nth-of-type(1):hover{
    background-position: center;
}
    .photo:nth-of-type(2):hover{
      background-position: bottom;
}
    
    .photo:nth-of-type(3):hover{
     background-position: top;
}
    
    .photo:nth-of-type(4):hover{
      background-position: bottom;
}
    
    .contact button:hover {
    color: black;
    background-color: white;
  }
    .text i:hover{
    transform: scale(1.5);
    }
    
    .text:hover{
         background-color: black;
 }
    .text p:hover{
        border-top: 3px solid white;
    } 
}

@media (max-width: 823px) and (orientation: landscape){
    nav{
        font-size: 12px;
    }
    nav p
    {
        background-color: rgba(160, 202, 209, 0.93);
        line-height: 27px;
    }
    
    
    ul li a {
        margin-top: 5%;
    }
    
    .photo p{
        opacity: 1;
        font-size: 14px;
        text-transform: uppercase;
    }
     #discription{
        min-height: 40vh;
    }
    
    #story{
        margin-top: 9%;
        min-height: 40vh;
    }
}



@media (max-width: 738px) and (orientation: landscape){
    nav p 
    {
        background-color: rgba(160, 202, 209, 0.93);
        padding-bottom: 1%;
        line-height: 15px;
    }
    nav ul
    {
     max-height: 8vh;
    }
    nav ul li a i
    {
        font-size: 12px;
    }
    nav ul li a{
        padding-top: 80%;
        line-height: 33.3%;
    }
    
    .photo p{
        opacity: 1;
        font-size: 14px;
        text-transform: uppercase;
    }
    
     #discription{
        min-height: 40vh;
    }
    
    #story{
        margin-top: 9%;
        min-height: 40vh;
    }
    
}
@media (max-width: 668px) and (orientation: landscape){
    
    
    nav
    {
        position: fixed;
         background-color: rgba(160, 202, 209, 0.93);
    }
    
    nav ul li a{
        font-size: 12px;
    }
    
    nav ul li a i
    {
        font-size: 12px;
    }
    nav p {
         background-color: rgba(160, 202, 209, 0.93);
        padding-top: 1%;
        text-align: center;
        float: none;
        padding: 0;
        padding-top: 1%;
        max-height: 8vh;
    }
    nav ul 
    {
        background-color:#deb887;
    }
    
    .photo p{
        opacity: 1;
        font-size: 14px;
        text-transform: uppercase;
    }
    
    #discription{
        min-height: 40vh;
    }
    
    #story{
        margin-top: 9%;
        min-height: 40vh;
    }
       
}
@media(max-width:300px){
    body * {
        max-width: 100vw;
    }
}


@media(min-width: 100px){
    body * {
        max-width: 100vw;
}
}

 

komentarz 11 maja 2020 przez Piotr Młynarczyk Początkujący (380 p.)
edycja 11 maja 2020 przez Piotr Młynarczyk
Nie wiem czy o to chodzi, ale dodaj do body czerwone tło i obejrzyj stronę na małym ekranie. Coś wystaje i to mocno w zależności od szerokości ekranu.

Podobne pytania

0 głosów
1 odpowiedź 740 wizyt
0 głosów
1 odpowiedź 405 wizyt
pytanie zadane 26 stycznia 2020 w HTML i CSS przez renegat Obywatel (1,040 p.)
+1 głos
1 odpowiedź 327 wizyt

93,741 zapytań

142,676 odpowiedzi

323,294 komentarzy

63,322 pasjonatów

Motyw:

Akcja Pajacyk

Pajacyk od wielu lat dożywia dzieci. Pomóż klikając w zielony brzuszek na stronie. Dziękujemy! ♡

Oto polecana książka warta uwagi.
Pełną listę książek znajdziesz tutaj

Twierdza Linux. Bezpieczeństwo dla dociekliwych

Aby uzyskać rabat -10%, użyjcie kodu pasja-linux, wpisując go w specjalne pole w koszyku.

...