How do I use flexbox together with Polymer to make tables

匆匆过客 提交于 2019-12-11 06:55:48

问题


I would like to use flexbox in Polymer to create tables out of divs. But the main problem is that by "cells" squish because of the content inside it when I change the size of the puter div. In the example below, try resizing the browser window. How do I get it to obey the size defined by flex as first priority while still wrapping text?

<!doctype html>
<html>
<head>
    <script src='../bower_components/webcomponentsjs/webcomponents-lite.js'></script>
    <link rel='import' href='../bower_components/iron-flex-layout/iron-flex-layout-classes.html'>
</head>
<body unresolved>
    <dom-module id='base-page'>
        <style include='iron-flex iron-flex-alignment'>
            .border {
                border: 1px solid red;
            }
        </style>
        <template>
            <div class='vertical layout' style='width:50%'>
                <div class='horizontal layout'>
                    <div class='flex border'>Short</div>    
                    <div class='flex border'>This is a muuuuuuuuuuuuuuuuuch longer text</div>    
                    <div class='flex border'>And this ie medium</div>    
                </div>
                <div class='horizontal layout'>
                    <div class='flex border'>e</div>    
                    <div class='flex border'>e</div>    
                    <div class='flex border'>e</div>    
                </div>
            </div>
        </template>
    </dom-module>
    <script>
        HTMLImports.whenReady(function() {Polymer({ 
            is: 'base-page'
        });});
    </script>
    <base-page></base-page>
</body>

Thanks

Cheers


回答1:


Adding this to your border class should solve the issue.

word-break: break-word;

<!doctype html>
<html>

<head>
  <base href="https://polygit.org/components/">
  <script src='webcomponentsjs/webcomponents-lite.js'></script>
  <link rel='import' href='polymer/polymer.html'>
  <link rel='import' href='iron-flex-layout/iron-flex-layout-classes.html'>
</head>

<body unresolved>
  <dom-module id='base-page'>
    <style include='iron-flex iron-flex-alignment'>
      .border {
        border: 1px solid red;
        word-break: break-word;
      }
    </style>
    <template>
      <div class='vertical layout' style='width:50%'>
        <div class='horizontal layout'>
          <div class='flex border'>Short</div>
          <div class='flex border'>This is a muuuuuuuuuuuuuuuuuch longer text</div>
          <div class='flex border'>And this ie medium</div>
        </div>
        <div class='horizontal layout'>
          <div class='flex border'>e</div>
          <div class='flex border'>e</div>
          <div class='flex border'>e</div>
        </div>
      </div>
    </template>
  </dom-module>
  <script>
    HTMLImports.whenReady(function() {
      Polymer({
        is: 'base-page'
      });
    });
  </script>
  <base-page></base-page>
</body>


来源:https://stackoverflow.com/questions/38388469/how-do-i-use-flexbox-together-with-polymer-to-make-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!