简体   繁体   English

重新设计移动优先设计

[英]Re-designing for Mobile First Design

I have already designed a webpage before learning about mobile-first design. 在学习移动优先设计之前,我已经设计了一个网页。

When creating a responsive design I made 3 classes: .mobile, .tablet, .desktop. 创建响应式设计时,我分为3类:.mobile,.tablet和.desktop。

I call to all these classes in my navigation bar, but apparently don't need to call to my mobile query when designing for mobile first (I understand why). 我在导航栏中调用了所有这些类,但是在为移动设备设计时,显然不需要调用移动查询(我知道为什么)。 Whenever I remove my .mobile class it shows the mobile information, and then when I re-size the window to a larger window the mobile information stays and then the tablet/desktop information is added. 每当我删除.mobile类时,它都会显示移动信息,然后,当我将窗口大小调整为更大的窗口时,移动信息会保留下来,然后添加平板电脑/台式机信息。 How would I go about correctly re-designing this? 我将如何正确地重新设计呢? This is my main content in working form when resizing windows. 这是我调整窗口大小时工作形式的主要内容。

 /*Mobile Query*/ @media only screen and (max-width:480px) { .mobile { display: block; } .desktop, .tablet { display: none; } } /*Tablet Query*/ @media only screen and (min-width: 481px) and (max-width:768px) { .tablet { display: block; } .mobile, .desktop { display: none; } } /*Desktop Query*/ @media only screen and (min-width: 769px) { .desktop { display: block; } .mobile, .tablet { display: none; } } 
 <h2 class="mobile">About Me</h2> <p class="mobile">I will not disappoint and I will perform to the best of my ability.</p> <h2 class="tablet">About Me</h2> <p class="tablet"> I am somebody who tries their best not to disappoint. I fear that my disappointment will reflect poorly upon myself and people who are close to me. This is something that motivates me to work hard and not to complain. Currently, I work part-time at a grocery store, run a side business, and go to school more than full time.</p> </article> <h2 class="desktop">Strengths</h2> <p class="desktop">One of my strengths include being very talented at learning or developing new ways to complete objectives. I always enjoy learning about different perspectives, and I believe it is needed to be successful. Another one of my strengths is the ability to see an error and immediately want to correct it rather than ignoring it and leaving somebody else to fix it. I am driven to be the best at anything I do while wanting to help other people and make their jobs easier.</p> 

So I've managed to answer half of my question so far. 到目前为止,我已经回答了一半的问题。 In the beginning I had for my Nav bar: 一开始我有导航栏:

<nav>
<div class= "mobile">
    <li><a href="index.html">Home</a></li>
    <li><a href="portfolio.html">About Me</a></li> 
    <li><a href="projects.html">My Projects</a></li> 
    <li><a href="contact.html">Contact Me</a></li>
    <li><a href="education.html">My Education</a></li>
</div>

<div class="tablet">
    <li><a href="index.html">Home</a></li>
    <li><a href="portfolio.html">About Me</a></li> 
    <li><a href="projects.html">My Projects</a></li> 
    <li><a href="contact.html">Contact Me</a></li>
    <li><a href="education.html">My Education</a></li>
</div>

<div class="desktop">
    <ul><a href="index.html">Home</a></ul>
    <ul><a href="portfolio.html">About Me</a></ul> 
    <ul><a href="projects.html">My Projects</a></ul> 
    <ul><a href="contact.html">Contact Me</a></ul>
    <ul><a href="education.html">My Education</a></ul>
</div>
</nav>

and it is now: 现在是:

<nav>
    <li><a href="index.html">Home</a></li>
    <li><a href="portfolio.html">About Me</a></li> 
    <li><a href="projects.html">My Projects</a></li> 
    <li><a href="contact.html">Contact Me</a></li>
    <li><a href="education.html">My Education</a></li>
</nav>

Because I changed my .desktop query 因为我更改了.desktop查询

/*Desktop Query*/
@media only screen and (min-width: 769px) {
    .desktop {
        display: block;
    }
    .mobile, .tablet {
        display: none;
    }
    nav li {
        background-color: #FFA500;
        border-radius: 1em;
        list-style-type: none;
        padding-left: .3em;
        padding-right: .3em;
        margin-left: 1%;
        margin-right: 1%;
        display: inline;
        margin-bottom: 2em;
        font-size: 1.2em;
    }
}

My mobile and tablet information were the same in this case, with the only changes coming to this section being visual changes, so I changed my desktop query to include the visual changes instead of using li for one set of changes and ul for another. 在这种情况下,我的手机和平板电脑信息是相同的,本节中唯一的更改是视觉更改,因此我更改了桌面查询以包括视觉更改,而不是使用li进行一组更改而使用ul进行另一组更改。

For hiding content and displaying content, I kept the classes and removed my mobile query. 为了隐藏内容和显示内容,我保留了类并删除了移动查询。 I still retained the .mobile class. 我仍然保留.mobile类。 I added display: none to both my tablet/desktop classes so that they will never be displayed, but then with my tablet/desktop query, it has display: block, so it blocks the none display revealing them depending on viewport size. 我在平板电脑/台式机类中都添加了display:none,因此它们将永远不会显示,但是在我的平板电脑/台式机查询中,它具有display:块,因此它会根据视口的大小阻止none显示,以显示它们。

Example: If my screensize is 500 pixels, it will classify as a desktop viewport, so my query tells my HTML to hide my .mobile and .tablet class, which tablet class is already hidden. 示例:如果我的屏幕尺寸为500像素,它将被归类为桌面视口,因此我的查询告诉我的HTML隐藏了.mobile和.tablet类,该类已经被隐藏了。 It also tells my HTML to block the previos display command to my .desktop class, which was to hide it, so it ends up showing it. 它还告诉我HTML将previos display命令阻止到我的.desktop类,该命令将其隐藏,因此最终显示了它。 I hope this is even interpretable. 我希望这是可以解释的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM