Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
150 views
in Technique[技术] by (71.8m points)

html - CSS flexbox responsive ui

I'm trying to design a page avoiding code duplications.

Basically, I have a page with a filter component on the left and results on the right with a summary header.

On the mobile, the filter component is inside the summary header.

Playing with the display property I can achieve that, but don't want to duplicate html like in the following code.

<!DOCTYPE html>
<html lang='en'>
<head>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  <meta charset='UTF-8'>
</head>
<body>
<div class='container'>
  <div class='row'>
    <div class='d-none d-lg-flex col-lg-3'>DUPLICATED</div>
    <div style='background-color:darkslategrey' class='col-12 col-lg-9'>
      <div class='row'>
        <div style='background-color:red' class='col-3 col-lg-6'>counter</div>
        <div style='background-color:grey' class='col-4 d-lg-none'>DUPLICATED</div>
        <div style='background-color:green' class='col-5 col-lg-6'>sorting</div>
      </div>
      <div class='row'>
        <div class='col-12'>results</div>
      </div>
    </div>
  </div>
</div>
</body>
</html>
question from:https://stackoverflow.com/questions/65834898/css-flexbox-responsive-ui

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I guess there's no way to do it using flexbox without repeating the markup. You should rather consider using grid layout.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...