您能帮助我设计我的投资组合网站吗?

问题描述 投票:-1回答:1

嗯,我正在制作自己的作品集,并且在媒体查询方面遇到问题。我在PC屏幕上有一个优化设计,但是当我在智能手机上输入它时,它不能正常工作。

这是媒体查询的CSS部分。如果您需要它,我可以输入所有代码:

$(document).ready(function () {
    $('.menu-toggler').on('click', function () {
        $(this).toggleClass('open');
        $('.top-nav').toggleClass('open');
    });

    $('.top-nav .nav-link').on('click', function () {
        $('.menu-toggler').removeClass('open');
        $('.top-nav').removeClass('open');
    });

    $('nav a[href*="#"]').on('click', function () {
        $('html, body').animate( {
            scrollTop: $($(this).attr('href')).offset().top - 100
        }, 1500);
    });

    $('#up').on('click', function () {
        $('html, body').animate( {
            scrollTop: 0
        }, 1500);
    });

    AOS.init({
        easing: 'ease',
        duration: 1200,
        once: true,
    });
});
/*Start global*/
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html{
    font-size: 10px;
    font-family: 'Raleway', sans-serif;
    color: #eee
}

body{
    width: 100%;
    height: 100%;
    background: url(images/3623463-3.jpg) no-repeat center fixed;
    background-size: cover;
}

section{
    padding: 6rem;
}

a{
    text-decoration: none;
    color: #eee;
}

p{
    font-size: 1.8rem;
    font-weight: 300;
}

img{
    width: 100%;
}
/*End global*/

/*Start reusable*/

.container{
    width: 90%;
    max-width: 120rem;
    height: 100%;
    margin: 0 auto;
    position: relative;
}

.section-heading{
    text-align: center;
    margin-bottom: 10rem;
}

.section-heading h1{
    font-size: 3.5rem;
    color: rgba(255, 255, 255, 0.733);
    text-transform: uppercase;
    font-weight: 300;
    position: relative;
    margin-bottom: 1rem;
}

.section-heading h1::before,
.section-heading h1::after{
    content: '';
    position: absolute;
    bottom: -.5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.788);
}

.section-heading h1::before{
    width: 10rem;
    height: 3px;
    border-radius: .8rem;
}

.section-heading h1::after{
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 100%;
    bottom: -1rem;
}

.section-heading h6{
    font-size: 1.6rem;
    font-weight: 300;
}

.has-margin-right{
    margin-right: 5rem;
}
/*End reusable*/


/*Start header*/

header {
    width: 100%;
    height: 100vh;
}

.top-nav{
    width: 100%;
    height: 100vh;
    position: fixed;
    top: -100vh;
    z-index: 50;
    background-color: #000000; 
    border-bottom-right-radius: 100%;
    border-bottom-left-radius: 100%;
    transition: all 650ms cubic-bezier(1,0,0,1);
}

.nav-list{
    list-style: none;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

li {
    margin: 0 2rem;
}

.nav-link {
    font-family: 'Righteous', cursive;
    font-size: 3.5rem;
    padding: 1rem;
}

.nav-link:hover,
.nav-link:focus{
    background: linear-gradient(to top, #0000c9, #ffffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-nav.open{
    top: 0;
    border-radius: initial;
}

.menu-toggler{
    position: absolute;
    top: 5rem;
    right: 5rem;
    width: 5rem;
    height: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    z-index: 1500;
    transition: transform 650ms ease-out;
}

.menu-toggler.open{
    transform: rotate(-45deg);
}

.bar{
    background: linear-gradient(to right, #ffffff, #0000c9);
    width: 100%;
    height: 4px;
    border-radius: 3rem;
}

.bar.half{
    width: 50%;
}

.bar.start{
    transform-origin: right;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.57, 0.57);
}

.open .bar.start{
    transform: rotate(-450deg) translateX(.8rem);
}

.bar.end{
    align-self: flex-end;
    transform-origin: left;
    transition: transform 650ms cubic-bezier(0.54, -0.81, 0.57, 0.57);
}

.open .bar.end{
    transform: rotate(-450deg) translateX(-.8rem);
}

.my-logo{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 55%;
    z-index: 1;
}

/*End header*/

/*Start about*/

.about .container{
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: justify;
}

.about-heading{
    text-align: center;
    text-transform: uppercase;
    line-height: 0;
    margin-bottom: 6rem;
}

.about-heading h1{
    font-size: 10rem;
    opacity: .3;
}

.about-heading h6{
    font-size: 2rem;
    font-weight: 300;
}

.profile-img{
    flex: 1;
    margin-right: 5rem;
}

.about-details{
    flex: 1;
}

.social-media{
    margin-top: 5rem;
}

.social-media i{
    font-size: 5rem;
    transition: color 650ms;
}

.fa-youtube:hover{
    color: #0000c9
}

.fa-instagram:hover{
    color: #0000c9
}

.fa-github-square:hover{
    color: #0000c9
}


/*End about*/

/*Start services*/

.my-skills{
    margin-top: 10rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
    grid-gap: 2.5rem;
    text-align: center;
}

.skill{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.skill h1{
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 2rem -2px 2rem 0;
}

.icon-container{
    width: 10rem;
    height: 10rem;
    border: 3px solid #ffffff;
    background-color: #000000;
    margin-bottom: 2rem;
    display: flex;
    transform: rotate(45deg);
}

.icon-container i{
    color: rgb(0, 0, 201);
    font-size: 5rem;
    margin: auto;
    transform: rotate(-45deg);
}
/*End services*/


/*Start portfolio*/
.portfolio-item{
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5rem;
}

.portfolio-item:last-child{
    margin-bottom: 0;
}

.portfolio-img {
    flex:1;
    border: rgba(255, 255, 255, 0.123) 2px solid;
}

.portfolio-description {
    flex:1;
}

.portfolio-description h1{
    font-size: 3rem;
    font-weight: 300;
    margin: 1rem 0;
}

.portfolio-description h6{
    font-size: 1.5rem;
    text-transform: uppercase;
    font-weight: 300;
    opacity: 0.6;
}

.portfolio-description .cta{
    display: inline-block;
    margin-top: 2.5rem;
    font-size: 1.5rem;
    text-transform: uppercase;
    color: rgb(251, 255, 0);
    transition: color 650ms;
}

.portfolio-description .cta:hover{
    color: rgb(0, 0, 201);
}
/*End portfolio*/


/* Start others */

.others-item{
    margin-top: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5rem;
}

.others-item:last-child{
    margin-bottom: 0;
}

/* End others */

/* Video borders */

.video-item-in{
    border: rgba(255, 255, 255, 0.123) 2px solid;
}

/* End video borders */

/*Start timeline*/

.timeline ul{
    border-left: 4px solid #ffe838;
    border-radius: .8rem;
    background-color: rgba(255, 255, 255, .3);
    margin: 0 auto;
    position: relative;
    padding: 5rem;
    list-style: none;
    text-align: left;
    width: 70%;
}

.timeline h1{
    font-size: 2rem;
    text-transform: uppercase;
    font-weight: 300;
    margin-bottom: 1rem;
    opacity: .3;
}

.timeline .date{
    border-bottom: 1px solid rgba(255, 255, 255, .3);
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    position: relative;
}

.timeline .date:last-of-type{
    padding-bottom: 0;
    margin-bottom: 0;
    border: none;
}

.timeline .date::before,
.timeline .date::after{
    position: absolute;
    display: block;
    top: 50%;
    transform: translateY(-50%);
}

.timeline .date::before{
    content: attr(data-date);
    left: -21rem;
    text-align: right;
    min-width: 12rem;
    font-size: 1.5rem;
}

.timeline .date::after{
    content: '';
    box-shadow: 0 0 0 4px #ffe838;
    border-radius: 100%;
    left: -7.7rem;
    height: 1.5rem;
    width: 1.5rem;
    background-color: #313534;
}
/*End timeline*/

/*Start contact*/
.contact{
    background-color: #202020af;
}

form{
    width: 70%;
    margin: 0 auto;
}

form label{
    font-size: 1.5rem;
}

input,
select,
textarea{
    width: 100%;
    padding: 1rem;
    margin-bottom: 5px;
    border: none;
    outline-color: rgba(255, 255, 255, .3);
}

input[type="submit"]{
    width: initial;
    background-color: #ffffff;
    color: rgb(0, 0, 0);
    padding: 1rem 2rem;
    border-radius: .8rem;
    cursor: pointer;
    transition: background-color 650ms;
}

input[type="submit"]:hover{
    color: #ffffff;
    background-color: rgba(255, 255, 255, .3);
}
/*End contact*/

/*Start footer*/

.copyright{
    width: 100%;
    text-align: center;
    background-color: rgba(7, 7, 8, 0.863);
    padding: 2rem 0;
    position: relative;
}

.up{
    position: absolute;
    width: 5rem;
    height: 5rem;
    background-color: rgba(255, 255, 255, .3);
    top: -2.5rem;
    right: 5rem;
    border-radius: 100%;
    display: flex;
    animation: pulse 2s infinite;
    cursor: pointer;
}

.up i{
    color: #ffffff;
    font-size: 2rem;
    margin: auto;
}

.copyright p{
    font-size: 1.4rem;
}
/*End footer*/

/*Start animations*/
@keyframes pulse{
    0%{
        box-shadow: 0 0 0 0 rgba(255, 255, 255, .3);
    }
    70%{
        box-shadow: 0 0 0 2rem rgba(255, 255, 255, .3);
    }
    100%{
        box-shadow: 0 0 0 0 rgba(255, 255, 255, .3);
    }
}
/*End animations*/

/*Start media queries*/

@media screen and (max-width: 768px) {
    body {
        background: url(images/3623463-4.jpg) no-repeat center fixed;
        background-size: cover;
    }

    .landing-text h1{
        font-size: 15rem;
    }

    .landing-text h6{
        font-size: 1.7rem;
    }

    .nav-list{
        flex-direction: column;
    }

    li{
        margin: 2rem 0;
    }

    .nav-link{
        font-size: 4.5rem;
    }
    
    .about-heading h1{
        font-size: 8rem;
    }

    .section-heading h1{
        font-size: 3rem;
    }

    .about-details .nav-list{
        flex-direction: initial;
    }

    .about-details li{
        margin: 0 2rem;
    }

    .icon-container{
        width: 7rem;
        height: 7rem;
    }

    .icon-container i{
        font-size: 4rem;
    }

    .timeline ul{
        margin: 0 0 0 auto;
    }

    .timeline .date::before{
        left: -20rem;
    }

    .timeline .date::after{
        left: -5.9rem;
    }
}

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

    .my-logo{
        width: 85%;
    }

    .menu-toggler{
        top: 2rem;
        right: 2rem;
    }

    .landing-text h1{
        font-size: 8rem;
    }

    .landing-text h6{
        font-size: 1.4rem;
    }

    .nav-link{
        font-size: 3.5rem;
    }

    .about .container{
        flex-direction: column;
    }

    .profile-img{
        margin: 0 0 7rem 0;
    }

    .portfolio-item{
        flex-direction: column;
    }

    .portfolio-img{
        margin: 0 0 2rem 0;
        order: 1;
    }

    .portfolio-description{
        margin: 0;
        order: 2;
    }

    .timeline p{
        font-size: 1.6rem;
    }

    .timeline .data::before{
        font-size: 1.4rem;
    }

    form{
        width: 100%;
    }

    .up{
        right: 2rem;
    }

    /* Video settings */

    .video-item-in{
        position: relative;
        width: 100%;
        padding-bottom: 56.25%; 
        height: 0;
        margin-right: auto;
      }
    
    .video-item-in iframe{
        position: absolute;
        top:0;
        left: 0;
        width: 100%;
        height: 100%;
      }    

}
/*End media queries*/
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Carlos Pérez</title>
    <link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
    <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@300&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Righteous&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
    <link rel="stylesheet" href="main.css">
</head>
<body>
    <header>
        <div class="menu-toggler">
            <div class="bar half start"></div>
            <div class="bar"></div>
            <div class="bar half end"></div>
        </div>

        <nav class="top-nav">
            <ul class="nav-list">
                <li>
                    <a href="index.html" class="nav-link"> Home </a>
                </li>
                <li>
                    <a href="#about" class="nav-link"> About </a>
                </li>  
                <li>
                    <a href="#services" class="nav-link"> Services </a>
                </li>    
                <li>
                    <a href="#portfolio" class="nav-link"> Portfolio </a>
                </li>    
                
                <!--<a href="#experience" class="nav-link"> Experience </a> -->
               
                <li>
                    <a href="#others" class="nav-link"> Other</a>
                </li>    
                <li>
                    <a href="#contact" class="nav-link"> Contact </a>
                </li>
            </ul>

        </nav>
        <div class="my-logo">
            <h1>
                <img src="images/my propio logotipo(Solo Logo, sin fondo).png">
            </h1>
        </div>

    </header>

        <!-- About me section -->

    <section class="about" id="about">
        <div class="container">
            <div class="profile-img" data-aos="fade-right" data-aos-delay="100">
                <img src="images/IMG_3383.jpg" alt="">
            </div>
            <div class="about-details" data-aos="fade-left" data-aos-delay="200">
                <div class="about-heading">
                    <h1> About </h1>
                    <h6> Myself</h6>
                </div>
                <p> Hello, I'm Carlos. <span style="color: #2b2bff; font-size: 3rem">I'm a web developer.</span> I also work in other fields such as graphic and video design. In my spare time I compose music, indeed. Creativity and hard-work are my life philosophy. Please have a seat, scroll down and check out my career and activities:
                </p>

                      <!-- Social networks-->

                <div class="social-media">
                    <ul class="nav-list">
                        <li>
                            <a href="https://www.youtube.com/c/CarlosP%C3%A9rezMusic" target="_blank" class="icon-link">
                                <i class="fab fa-youtube"></i>
                            </a>
                        </li>
                        <li>
                            <a href="https://www.linkedin.com/in/carlos-p%C3%A9rez-724751143/" target="_blank" class="icon-link">
                                <i class="fab fa-linkedin"></i>
                            </a>
                        </li>
                        <li>
                            <a href="https://github.com/CarlosPerezMoreno" target="_blank" class="icon-link">
                                <i class="fab fa-github-square"></i>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>


            <!-- Services -->

    <section class="services" id="services">
        <div class="container">
            <div class="section-heading">
                <h1>Services</h1>
                <h6>What can i do for you?</h6>
            </div>
            <div class="my-skills">
                <div class="skill" data-aos="fade-in" data-aos-delay="100">
                    <div class="icon-container">
                        <i class="fas fa-code"></i>
                    </div>
                    <h1> Web Development </h1>
                    <p> Skill with programming languages such as HTML5, CSS3 and JavaScript. I use JS libraries like React or JQuery. Other tools that i use are Git, Bootstrap, Node.js, and i'm in progress to learn Angular.</p>
                </div>
                <div class="skill" data-aos="fade-in" data-aos-delay="200">
                    <div class="icon-container">
                        <i class="fas fa-video"></i>
                    </div>
                    <h1>Video Edition</h1>
                    <p> Skill with Adobe package video tools: Adobe Premiere and Adobe After Effects. I have my own YouTube Channel, in which i upload all my video and music projects: shortfilms, my own music pieces, music covers and much more. </p>
                </div>
            </div>
        </div>
    </section>

            <!-- Portfolio -->

    <section class="portfolio" id="portfolio">
        <div class="container">
            <div class="section-heading">
                <h1>Portfolio</h1>
                <h6>Some of my projects</h6>
            </div>

                <!-- 1st project-->

            <div class="portfolio-item">
                <div class="portfolio-description has-margin-right" data-aos="fade-right" data-aos-delay="100">
                    <h6>Web Development</h6>
                    <h1>My Own Portfolio</h1>
                    <p>This proper portfolio has been developed and designed for me. It is based on HTML5, CSS3 and JavaScript, combined with a little bit of JQuery library.
                    </p>
                    <a href="https://github.com/CarlosPerezMoreno/MyProfessionalWebPage" target="_blank" class="cta">View Details</a>
                </div>
                <div class="portfolio-img" data-aos="fade-left" data-aos-delay="200">
                    <img src="images/Autocapture portfolio top.jpg" alt="">
                </div>
            </div>

                <!-- 2nd project -->

            <div class="portfolio-item">
                <div class="portfolio-img has-margin-right" data-aos="fade-right" data-aos-delay="300">
                    <img src="images/Underconstruction.jpg" alt="">
                </div>
                <div class="portfolio-description" data-aos="fade-left" data-aos-delay="400">
                    <h6>Web Development</h6>
                    <h1>UNDER CONSTRUCTION</h1>
                    <p>Stay tuned for following works and projects.
                    </p>
                    <a href="#" class="cta">View Details</a>
                </div>
            </div>

             <!-- 3rd project -->

            <div class="portfolio-item">
                <div class="portfolio-description has-margin-right" data-aos="fade-right" data-aos-delay="100">
                    <h6>Video Edition</h6>
                    <h1>Shortfilm Opening</h1>
                    <p>Here is an opening created by a mini-show developed by Fine Arts Faculty of UCLM (Spain). It's made from After Effects and Premiere.
                    </p>
                </div>
                <div class="video-item-in" data-aos="fade-left" data-aos-delay="200">
                     <iframe width="560" height="315" src="https://www.youtube.com/embed/qgv1iV9nvQg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
                    </iframe>
                </div>
            </div>

            <!-- 4th project -->

            <div class="portfolio-item">
                <div class="video-item-in has-margin-right" data-aos="fade-left" data-aos-delay="200">
                    <iframe width="560" height="315" src="https://www.youtube.com/embed/bxxIrQ44DbM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
                    </iframe>
                </div>
                <div class="portfolio-description" data-aos="fade-left" data-aos-delay="400">
                    <h6>Video Edition</h6>
                    <h1>Live Concert</h1>
                    <p>Live recording for Dissaverage Band (Albacete), in one of its concerts. Edited with Premiere.
                    </p>
                </div>
            </div>
        </div>
    </section>


            <!-- Experience -->

   <!-- <section class="experience" id="experience">
        <div class="container">
            <div class="section-heading">
                <h1>Work Experience</h1>
                <h6>Past and current jobs</h6>
            </div>
            <div class="timeline">
                <ul>
                    <li class="date" data-date="2018 - Present">
                        <h1> GOOGLE </h1>
                        <p> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Id nisi debitis dolor? Atque neque cumque ea eligendi, ut explicabo alias iste rerum minima sint qui quo, maiores, in et tenetur!</p>
                    </li>
                </ul>
            </div>
        </div>
    </section> -->

         <!-- Other -->

    <section class="others" id="others">
        <div class="container">
            <div class="section-heading" data-aos="fade-down" data-aos-delay="100">
                <h1>Other interests and activities</h1>
                <h6>Music</h6>
                <br>
                <p>Music is one of my passions. I have composed soundtrack for some projects: <a href="https://play.google.com/store/apps/details?id=com.NLHs.JumpHit" target="_blank"><u>JUMP HIT</u></a> videogame by <a href="https://nlhstories.wixsite.com/welcome" target="_blank"><u>NLHStories</u></a> or "Pei" animation shortfilm by Lightbox Academy. Here is some of my pieces:
                </p>

                <!-- 1st video -->
                <div class="others-item">
                    <div class="video-item-in" data-aos="fade-down" data-aos-delay="200">
                        <iframe width="560" height="315" src="https://www.youtube.com/embed/Tc-JYpWaVsI" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
                        </iframe>
                    </div>
                </div>
                <div class="others-item">
                    <div class="video-item-in" data-aos="fade-down" data-aos-delay="200">
                        <iframe width="560" height="315" src="https://www.youtube.com/embed/bWV1v5P-ZzM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
                        </iframe>
                    </div>
                </div>
            </div>
        </div>
    </section>

        <!-- Contact -->

    <section class="contact" id="contact">
        <div class="container">
            <div class="section-heading" data-aos="fade-up" data-aos-delay="200">
                <h1> Contact </h1>
                <h6> Let's work together.</h6>
            </div>     
            <form action="" method="POST" data-netlify="true" data-aos="fade-up" data-aos-delay="300">
                <label for="name"> Name: </label>
                <input type="text" id="name" name="name" placeholder="Enter your name..." required>

                <label for="email"> Email: </label>
                <input type="email" id="email" name="email" placeholder="Enter your email..." required>

                <label for="service"> Services: </label>
                <select name="service" id="service">
                    <option value=""> Web Development </option>
                    <option value=""> Video Edition </option>
                    <option value=""> Music </option>
                </select>

                <label for="subject"> Subject: </label>
                <textarea name="subject" id="subject cols="10" rows="10"></textarea>
                <input type="submit" value="Submit">
            </form>
        </div>
    </section>

        <!-- Footer -->

    <footer class="copyright">
        <div class="up" id="up">
            <i class="fas fa-chevron-up"></i>
        </div>
        <p>&copy;2020 Carlos Pérez</p>
    </footer>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://unpkg.com/aos@next/dist/aos.js"></script>
    <script src="main.js"></script>
</body>
</html>

主要问题是智能手机中的内容未居中。我希望内容可以像PC屏幕一样固定,但是例如手机允许缩放。

我不知道是否可以链接到该网页(您可以让我知道)。

谢谢!

css responsive-design media-queries screen responsive-images
1个回答
0
投票

不确定您走了多远,但是下次尝试考虑优先开发移动设备。针对最小的屏幕尺寸进行优化,然后在增加屏幕尺寸时通过添加功能来逐步升级。

因此,可以使您的内容居中:

.content-to-center {
  // if it's text
  text-align: center;

  // if it's an image
  display: block
  margin: 0 auto;
}

然后您的媒体查询将查找超出您想要保持居中的最大屏幕尺寸的任何内容:


// For screen sizes more than 375px wide, do this
@media screen and (min-width: 375px) {
    .content-to-center {
      // styles you'd like to apply on larger screens
      // maybe undo centering here
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.