Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对屏幕适配进行总结 #35

Open
253867843 opened this issue Sep 23, 2019 · 0 comments
Open

对屏幕适配进行总结 #35

253867843 opened this issue Sep 23, 2019 · 0 comments
Assignees
Labels
css css学习 react react学习

Comments

@253867843
Copy link
Owner

对屏幕适配进行总结

  • 本文不是做网页端和手机端之间的任意适配.
    1.代码
<div className='container'>
    <div className='leftContent'>
        <item></item>
        <item></item>
        <item></item>
        <item></item>
        <item></item>
        ...
    </div>
    <div className='rightSidebar'>
    </div>  
</div>

2.rightSidebar宽度固定, 不随网页宽度的变化而变化
3.container和leftContent宽度根据网页宽度的变化而变化
4.css代码:

<div className='container'>...</div>
@media screen and (max-width: 1400px) {
    width: 980px;
}
width: 1160px;
上述代码表示: 
    当网页宽度<=1400px时, width === 980px
    当网页宽度>1400px时, width === 1160px
    以1400px作为分界线

-----
<div className='leftContent'>    
@media screen and (max-width: 1400px) {
    width: 720px;
}    
width: 900px;
上述代码表示:
    当网页宽度<=1400px时, width === 720px
    当网页宽度>1400px时, width === 900px
    以1400px作为分界线
    
-----    
<item>...</item>
item盒子模型宽度 = item宽度(160px) + marginRight(20px) 
    + 没有marginLeft + 没有padding + 没有border
    = 180px

所以, 屏幕适配的结果是能够让 <div className='leftContent'> 在一行中多放置一个<item>盒子模型

网页宽度 <= 1400px时,
720px/180px = 4个<item>盒子模型;

网页宽度 > 1400px时,
<div className='container'>由 1160px - 980px = 180px;
<div className='leftContent'> 由 900px - 720px = 180px;
180px === 正好等于一个<item>盒子模型的宽度               

在之后使用时, 需要简单计算
1.计算<item>盒子模型的宽度
2.以网页的多少宽度(上面是1400px)作为分界线
3.根据<item>盒子模型的宽度, 来计算 <= 1400px 时宽度 和 > 1400px 时宽度
after - before = <item>盒子模型宽度
@253867843 253867843 added css css学习 react react学习 labels Sep 23, 2019
@253867843 253867843 self-assigned this Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css学习 react react学习
Projects
None yet
Development

No branches or pull requests

1 participant