首页 > 其他分享 >CSS弹性盒子

CSS弹性盒子

时间:2023-10-09 19:44:07浏览次数:37  
标签:flex 盒子 color 100px 弹性 width background 对齐 CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /*父元素属性:
        display开启弹性盒子 默认为横向摆放
        flex-direction:指定子元素在父类中的摆放位置 row水平,左对齐 row-revrese反转,右对齐column上对齐 column-reverse 反纵向,下对齐
        justify-content:上下对齐方式
         align-items:左右对齐方式
        */
        .songs{
            width: 700px;
            height: 500px;
            background-color: slateblue;
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
        }
        /*子元素属性:
        flex-grow/flex:根据比分配空间,其权重  在之后 宽度属性不生效,其优先级高于宽度
         */
        .box1{
            width: 100px;
            height: 100px;
            background-color: red;
            flex-grow: 1;
        }
        .box2{
            width: 100px;
            height: 100px;
            background-color:green;
            flex-grow: 3;
        }
        .box3{
            width: 100px;
            height: 100px;
            background-color: blue;
            flex-grow: 1;
        }
    </style>
</head>
<body>
    <div class="songs">
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
    </div>
</body>
</html>

在父类元素的属性中确定元素的摆放位置

标签:flex,盒子,color,100px,弹性,width,background,对齐,CSS
From: https://www.cnblogs.com/songs7/p/17752993.html

相关文章

  • CSS盒子模型
    对html进行封装:包括外边距、边框、内边距和实际内容<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title......
  • 自定义滚动条 css
    /*自定义滚动条css*/.customScrollbar::-webkit-scrollbar{width:10px;height:10px;}.customScrollbar::-webkit-scrollbar-thumb{border-radius:8px;background-color:#47515b;}.customScrollbar::-webkit-scrollbar-thumb:hover{background-color:#5D626C;}.customScr......
  • css自定义滚动条
    .container{width:200px;height:150px;overflow:auto;/*自动显示滚动条/-ms-overflow-style:scrollbar;/在IE上显示自定义滚动条*/}/*自定义滚动条的样式*/.container::-webkit-scrollbar{width:10px;height:10px;}.container::-webkit-scrollbar-trac......
  • 在线直播源码,CSS磨砂玻璃效果和渐变主题色文字
    在线直播源码,CSS磨砂玻璃效果和渐变主题色文字HTML <divclass="card"> <h2class="gradient"> </h2> <div>  <p>.welcome{</p>  <pclass="indent">"CSDN:lqj_本人"</p>  <pclass="......
  • CSS~等待效果实现
    <style>.first-loading-wrp{display:flex;justify-content:center;align-items:center;flex-direction:column;min-height:420px;height:100%;margin-top:150px;}.first-loading-wrp.loadin......
  • scss基础
    官网https://www.sass.hk/guide/变量导入SASS文件静默注释混合器选择器继承style选项if指令for循环each循环while条件function函数文件后缀sass有两种后缀名文件:后缀名为sass,不使用大括号和分号后缀名为scss,这种和我们平时写的css文件格式......
  • 移动端弹性布局
    前言在PC端中,子容器高度超出父容器高度,通常使用overflow:auto可出现滚动条拖动显示溢出的内容而移动web开发中,由于浏览器厂商的系统不同、版本不同,会有部分机型不支持弹性滚动上图如果在PC端中,我们可以利用position:fixed和overflow:auto进行简单的布局实现我们需要......
  • CSS常用总结
    重置样式html,body,ul,li,a,p,div{padding:0;margin:0;//设置盒模型box-sizing:border-box;//移除移动端特有的点击高亮效果-webkit-tap-highlight-color:transparent;}body{font-family:"PingFangSC","MicrosoftYaHei","Helve......
  • CSS单位
    CSS常用长度单位px:相对长度单位相对于显示器屏幕分辨率rem:相对长度单位对于根元素(即html元素)font-size计算值的倍数html{font-size:14px;那么14px=1rem28px=2rem即:npx=n/14rem}h3{font-size=2rem;//转换为px即是2*12=24px}vw和vh移动端......
  • Vue学习笔记(七):绑定css样式
      1绑定class样式¶vue为HTML绑定css中的class样式是通过v-bind实现的。  1.1绑定单个class¶把需要绑定的样式class名赋值给一遍变量,然后通过变量v-bind绑定class属性,绑定后的class并不会覆盖原来的class属性,而是与原来的class进行叠加。如下所示,d......