美文网首页
css专题总结

css专题总结

作者: smartHui | 来源:发表于2019-06-25 14:02 被阅读0次

拿到视觉稿,首先确定内容区,如下:左右两边会各留20px(手机端左右留白,不用再特殊处理)

.content-grid {
  box-sizing: border-box;
  max-width: 1440px;
  min-width: 320px;
  margin: 0 auto;
  padding: 0 20px;
  overflow: hidden;
}

1、经典的文字布局,如下:使用flex布局

image.png
.featured-products-ul {
   display: flex;
   flex-wrap: wrap;
   margin: 0 -10px; `消除最左边和最右边的10px`
}
.featured-products-item {
    width: 20%;  //`控制元素宽度`
    border-radius: 3px;
}
.item-inner {
   margin: 0 10px 20px; //`相邻两个元素之间的距离,左右各10,累加即20px`
   background: #fff;
}
.item-inner-content {
  padding-top: 25px;
  padding-left: 20px;
  font-size: 14px;
  color: #555;
  line-height: 1.5;
  height: 235px;`高度固定,文字长度不一样`
}

2、banner展示有两种方式,一个是作为background,一个是img,分别如下:

 .banner-img {
      background: url("/Alexandria/img/promotions/yiwu-service/banner_yiwu.jpg") no-repeat top center;
      height: 670px;
      margin: 0 auto;
      background-size: cover;
    }


    .img-wrap {
            font-size: 0; `去除底部留白`
            img {
                max-width: 100%;
                max-height: 100%;
                border-radius: 0 6px 6px 0;
            }
        }

3、flex巧用:pc-文字在左,图片在右;mobile-图片在上,文字在下

pc.png mobile.png
<div class="banner">
//图片再右
  <div class="banner-right">
    <div class="img-wrap">
      <img src="">
    </div>
  </div>
//文字在左
  <div class="banner-left"></div>
</div>
.banner {
    display: flex;
    max-width: 1440px;
    min-width: 320px;
    margin: 0 auto;
    justify-content: space-between;
    flex-direction: row-reverse;  `//逆序排序`
    .banner-left {
        width: 40%;
        background-color: #F5F7FA;
        padding-top: 60px;
        padding-left: 100px;
        box-sizing: border-box;
        border-radius: 6px 0 0 6px;
    }
    .banner-right {
        width: 60%;
        .img-wrap {
            font-size: 0;
            img {
                max-width: 100%;
                max-height: 100%;
                border-radius: 0 6px 6px 0;
            }
        }
    }
}
@media screen and (max-width: 767px) {
      .banner {
        flex-wrap: wrap;
        flex-direction: column; `//竖排`
        align-items: center;
        .banner-right {
            width: 100%;
            .img-wrap {
                text-align: center;
                img {
                    border-radius: 6px;
                }
            }
        }
        .banner-left {
            width: 100%;
            padding: 30px 20px 0;
            background-color: #fff;
        }
    }
 }

4、img:max-width:100%;max-height:100%;
5、flex布局 align-self:base-line

相关文章

  • Css专题总结

    选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...

  • Css专题总结

    选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...

  • css专题总结

    拿到视觉稿,首先确定内容区,如下:左右两边会各留20px(手机端左右留白,不用再特殊处理) 1、经典的文字布局,如...

  • Css渐变gradients深入理解

    css渐变(专题) 【目录】 css渐变(专题)线性渐变(linear-gradient)第一个参数(方向,可忽略...

  • css伪元素

    css 伪元素 详述: 这篇文章是继 css的伪类 与 css 伪类选择器 后的 CSS伪元素总结, 意在总结连贯...

  • Css渐变gradients深入理解

    css渐变(专题) css3定义了两种渐变:线性渐变(Linear Gradients)or 径向渐变(Radia...

  • css进阶专题

    CSS 学习思路宽度与高度(文档流)堆叠上下文icon 全解移动端页面(响应式)Flex 布局布局套路为什么这么多...

  • css reset 总结

    css reset 的总结

  • CSS学习总结

    学了有一小段时间前端了,今做个CSS的总结! 目录: CSS 简介 CSS 语法 CSS 选择器 CSS 引入方式...

  • CSS hack 原理

    参考文章: CSS hack大全&详解(什么是CSS hack) 要点总结: css hack 原理是:依据不同浏...

网友评论

      本文标题:css专题总结

      本文链接:https://www.haomeiwen.com/subject/qvazqctx.html