美文网首页
flutter设置定位,旋转,缩放,圆角,阴影,内联格式,文本摘

flutter设置定位,旋转,缩放,圆角,阴影,内联格式,文本摘

作者: 阿克兰 | 来源:发表于2019-11-13 11:42 被阅读0次

    定位

    // web定位
    <div class="greybox">
      <div class="redbox">
        Lorem ipsum
      </div>
    </div>
    
    .greybox {
      background-color: #e0e0e0; /* grey 300 */
      width: 320px;
      height: 240px;
      font: 900 24px Roboto;
      position: relative; 
    }
    .redbox {
      background-color: #ef5350; /* red 400 */
      padding: 16px;
      color: #ffffff;
      position: absolute;
      top: 24px;
      left: 24px; 
    }
    // flutter定位,stack
    var container = new Container( // grey box
      child: new Stack(
        children: [
          new Positioned( // red box
            child:  new Container(
              child: new Text(
                "Lorem ipsum",
                style: bold24Roboto,
              ),
              decoration: new BoxDecoration(
                color: Colors.red[400],
              ),
              padding: new EdgeInsets.all(16.0),
            ),
            left: 24.0,
            top: 24.0,
          ),
        ],
      ), 
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    

    旋转

    //web旋转
    <div class="greybox">
      <div class="redbox">
        Lorem ipsum
      </div>
    </div>
    
    .greybox {
      background-color: #e0e0e0; /* grey 300 */
      width: 320px;
      height: 240px;
      font: 900 24px Roboto;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .redbox {
      background-color: #ef5350; /* red 400 */
      padding: 16px;
      color: #ffffff;
      transform: rotate(15deg); }
    // flutter旋转
    var container = new Container( // gray box
      child: new Center(
        child:  new Transform(
          child:  new Container( // red box
            child: new Text(
              "Lorem ipsum",
              style: bold24Roboto,
              textAlign: TextAlign.center,
            ),
            decoration: new BoxDecoration(
              color: Colors.red[400],
            ),
            padding: new EdgeInsets.all(16.0),
          ),
          alignment: Alignment.center,
          transform: new Matrix4.identity()
            ..rotateZ(15 * 3.1415927 / 180),
        ), 
      ),
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    // web缩放
    <div class="greybox">
      <div class="redbox">
        Lorem ipsum
      </div>
    </div>
    
    .greybox {
      background-color: #e0e0e0; /* grey 300 */
      width: 320px;
      height: 240px;
      font: 900 24px Roboto;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .redbox {
      background-color: #ef5350; /* red 400 */
      padding: 16px;
      color: #ffffff;
      transform: scale(1.5); 
    }
    //flutter 缩放
    var container = new Container( // gray box
      child: new Center(
        child:  new Transform(
          child:  new Container( // red box
            child: new Text(
              "Lorem ipsum",
              style: bold24Roboto,
              textAlign: TextAlign.center,
            ),
            decoration: new BoxDecoration(
              color: Colors.red[400],
            ),
            padding: new EdgeInsets.all(16.0),
          ),
          alignment: Alignment.center,
          transform: new Matrix4.identity()
            ..scale(1.5),
         ), 
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    // web圆角
    <div class="greybox">
      <div class="redbox">
        Lorem ipsum
      </div>
    </div>
    
    .greybox {
      background-color: #e0e0e0; /* gray 300 */
      width: 320px;
      height: 240px;
      font: 900 24px Roboto;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .redbox {
      background-color: #ef5350; /* red 400 */
      padding: 16px;
      color: #ffffff;
      border-radius: 8px; 
    }
    // flutter 圆角
    var container = new Container( // grey box
      child: new Center(
        child: new Container( // red circle
          child: new Text(
            "Lorem ipsum",
            style: bold24Roboto,
          ),
          decoration: new BoxDecoration(
            color: Colors.red[400],
            borderRadius: new BorderRadius.all(
              const Radius.circular(8.0),
            ), 
          ),
          padding: new EdgeInsets.all(16.0),
        ),
      ),
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    // flutter 设置阴影
    var container = new Container( // grey box
      child: new Center(
        child: new Container( // red box
          child: new Text(
            "Lorem ipsum",
            style: bold24Roboto,
          ),
          decoration: new BoxDecoration(
            color: Colors.red[400],
            boxShadow: <BoxShadow>[
              new BoxShadow (
                color: const Color(0xcc000000),
                offset: new Offset(0.0, 2.0),
                blurRadius: 4.0,
              ),
              new BoxShadow (
                color: const Color(0x80000000),
                offset: new Offset(0.0, 6.0),
                blurRadius: 20.0,
              ),
            ], 
          ),
          padding: new EdgeInsets.all(16.0),
        ),
      ),
      width: 320.0,
      height: 240.0,
      decoration: new BoxDecoration(
        color: Colors.grey[300],
      ),
      margin: new EdgeInsets.only(bottom: 16.0),
    );
    // 设置圆或者椭圆
    var container = new Container( // grey box
      child: new Center(
        child: new Container( // red circle
          child: new Text(
            "Lorem ipsum",
            style: bold24Roboto,
            textAlign: TextAlign.center, 
          ),
          decoration: new BoxDecoration(
            color: Colors.red[400],
            shape: BoxShape.circle, 
          ),
          padding: new EdgeInsets.all(16.0),
          width: 160.0,
          height: 160.0, 
        ),
      ),
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    // 内联格式
    var container = new Container( // grey box
      child: new Center(
        child: new Container( // red box
          child:  new RichText(
            text: new TextSpan(
              style: bold24Roboto,
              children: <TextSpan>[
                new TextSpan(text: "Lorem "),
                new TextSpan(
                  text: "ipsum",
                  style: new TextStyle(
                    fontWeight: FontWeight.w300,
                    fontStyle: FontStyle.italic,
                    fontSize: 48.0,
                  ),
                ),
              ],
            ),
          ), 
          decoration: new BoxDecoration(
            backgroundColor: Colors.red[400],
          ),
          padding: new EdgeInsets.all(16.0),
        ),
      ),
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    // 文本摘要
    var container = new Container( // grey box
      child: new Center(
        child: new Container( // red box
          child: new Text(
            "Lorem ipsum dolor sit amet, consec etur",
            style: bold24Roboto,
            overflow: TextOverflow.ellipsis,
            maxLines: 1, 
          ),
          decoration: new BoxDecoration(
            backgroundColor: Colors.red[400],
          ),
          padding: new EdgeInsets.all(16.0),
        ),
      ),
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300],
    );
    
    

    相关文章

      网友评论

          本文标题:flutter设置定位,旋转,缩放,圆角,阴影,内联格式,文本摘

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