create table using weex - css

I need to build an app that has a table. I tried using html <table> tags to build a table. Even though it shows the table as i require when i run using npm run serve when i build an apk and run it on my android device the output is messed up.
Does anyone know how to build a table in weex.
And does anyone have any good documentations or tutorials regarding weex.
thanks

It looks like HTML but Weex does not render actual HTML on native. The <div>s you write are Weex components that get translated to the target platform.
So while running on a browser may render tables, until Weex has a default <table> component, it won't render on native as you expect.
You can create your own component and lay it out using flexbox.

As others have commented, Weex doesn't use HTML but rather has a XML syntax which looks alike. So you need to implement something akin to a using only <div>s. I had to do exacly that, so I might as well post it here.
<template>
<div class="table">
<div class="row heading">
<div class="cell headingColumn">Table</div>
<div class="cell">2</div>
<div class="cell">3</div>
</div>
<div class="row">
<div class="cell headingColumn">Row 1</div>
<div class="cell">2</div>
<div class="cell">3</div>
</div>
<div class="row">
<div class="cell headingColumn">Row 2</div>
<div class="cell">2</div>
<div class="cell">3</div>
</div>
</div>
</template>
<style scoped>
.table {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.row {
display: flex;
flex-direction: row;
justify-content: space-between;
height: 60px;
}
.cell {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
/*width: 100px;*/
padding: 20px;
}
.heading {
background-color: grey;
font-weight: bold;
}
.headingColumn {
width: 120px;
}
</style>
Copy and paste it into dotwe.org and it will work and be rendered as expected in Android & the web.
As a side note, if you specify fixed widths (or min-widths) for the columns, styling will be much easier. That's why I've specified a .headingColumn class and there's a commented width:100px value inside .cell.
BTW, you might need to edit the and add a tag inside them with the text content you want.

Related

How do I move one item under another in Flexbox? I am trying to get the price under the annual plan

I am trying to get the price under the annual plan.
.paymentsection {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 2rem;
}
<div class="paymentsection">
<img src="/images/icon-music.svg" alt="Music" class="icon-img" />
<div class="plan">Annual Plan</div>
<div class="price">$59.99/year</div>
</div>
Change
final image
The .plan and .price needs to be inside a div and then if display flex is applied to the paymentsection, you get your desired result.
<div class="paymentsection">
<img src="/images/icon-music.svg" alt="Music" class="icon-img" />
<div class="plan-container">
<div class="plan">Annual Plan</div>
<div class="price">$59.99/year</div>
</div>
Change
</div>
.paymentsection {
display: flex;
flex-direction: row;
}
.plan-container{
flex-grow:1;
}
You need different flex boxes for implementation your image. Each flex box should have different direction. first you need to wrap your .plan div and .price div with another div. This help you to separate pricing component:
<div class="paymentsection">
<img src="/images/icon-music.svg" alt="Music" class="icon-img" />
<div class="plan-wrapper">
<div class="plan">Annual Plan</div>
<div class="price">$59.99/year</div>
</div>
</div>
Change
next you need to set flex direction to your new div element. this is your desire style:
.paymentsection {
display: flex;
}
.plan-wrapper{
display: flex;
flex-direction: column; /* default is row */
}
this changes should fix your issue.
To have the pricing aligned below the text, you'd have to nest the div further and specify the styles of the nested div to be oriented vertically, i.e, flex-direction: column.
You could do something like this:
<div class="paymentsection">
<img src="/images/icon-music.svg" alt="Music" class="icon-img" />
<div class="pricing">
<div class="plan">Annual Plan</div>
<div class="price">$59.99/year</div>
</div>
</div>
Change
Styles for pricing class:
.pricing{
display:flex;
flex-direction: column;
}

how to Fix Display Message in multiple line

.abc{
white-space:pre-wrap;
}
<label >student</Label>:<span class="abc">He is a good boy </br> he is also kind'</span>
Say I am displaying the message in Angular application in 2 line Like this:
LabelStudent:Ram is a good boy,
he is also kind.
I want the second line message i.e. He is also kind, should be displayed just below the first message and not beneath the label
This can easily be achieved with flexbox. I have reproduced a demo over here.
HTML:
<div class="container">
<label>student :</label>
<div class="information">
<span>He is a good boy</span>
<span> he is also kind'</span>
</div>
</div>
CSS:
.container {
display: flex;
flex-direction: row;
}
.information {
display: flex;
flex-direction: column;
}

Flexbox Style Only Works When Manually Entered in Chrome Developer Tools

I am trying to get an ag-Grid to fill the vertical space in a panel on a page. If I put the style on the .HTML page like this:
<style>
.right_panel > div {
display: flex;
flex: 1;
height: 95%;
flex-direction: column;
}
</style>
... or include it in the Javascript:
$(".right_panel > div").css("display", "flex");
$(".right_panel > div").css("flex-direction", "column");
$(".right_panel > div").css("height", "95%");
$(".right_panel > div").css("flex", "1");
... the styles will correctly show up in the Chrome CSS Debugger:
... but my ag-Grid is crushed down to zero height.
{image of a page with a grid that only has a navbar under which there's a lot of white space}
Disabling them and retyping them into the CSS Debugger verbatim:
... and the grid works fine
{image of a page with a grid that properly fills the page}
Is there something obvious (obviously) that I'm missing? I've read questions like this one to get the grid to fill the available vertical space. Why does this seemingly correct css only work when manually entered in the CSS debugger, and how do I fix it in my code?
Heavily edited HTML for the page:
<html>
<head>...</head>
<body>
<div id="main-view" ui-view="" class="ng-scope">
<div class="vbox ng-scope">
<div class="vbox-grow page-sidebar ng-scope splitter_panel" split-v="splitterCtrl">
<main class="hbox-grow right_panel" style="width: 1233px;">
<div ui-view="" class="ng-scope"><div class="task page ng-scope"> <!-- THIS is the line with the CSS I'm editing -->
<div class="task page ng-scope">
<article class="page-content">
<ui-view class="ng-scope">
<article class="page-content ng-scope" style="height: 100%; background-color: aliceblue; display: flex; flex-direction: column; flex: 1;">
<div id="gridContainer" style="height: 100%; background-color: yellow; flex-direction: column; flex: 1 1 0%; display: flex;">
<!-- THIS is the div that gets populated with the ag-grid -->
<div id="gridContent" style="width: 100%; background-color: hotpink; flex: 1; display: flex; flex-direction: column;" class="ag-fresh">

Bootstrap 3 container with justify-content: space-between not working properly

I am trying to apply flex to bootstrap 3 container and found strange behaviour of child elements Here is the code.
<div class="container">
<div class="child">One</div>
<div class="child">Two</div>
</div>
.container {
display: flex;
justify-content: space-between;
}
(see example on jsfiddle JSFiddle)
I cannot find out what's the problem with the space-between.
Thank you for the help.
Combining Bootstrap 3 with Flexbox is not recommended.
That said, Bootstraps container class also uses both the pseudo elements, hence they will participate in the flex container being flex items, and here one can see them when giving them a small width/height and background color.
And as you can see, the justify-content: space-between; work as it is supposed to.
.container {
display: flex;
justify-content: space-between;
}
.container::before, .container::after {
width: 30px;
height: 30px;
background: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="child">One</div>
<div class="child">Two</div>
</div>
One workaround would be a wrapper
.container .flex {
display: flex;
justify-content: space-between;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="flex">
<div class="child">One</div>
<div class="child">Two</div>
</div>
</div>
I think the issue is that you're using a classname from bootstrap .container you're attempting to change the style. Just use a id instead of the classname container.
#main {
display: flex;
justify-content: space-between;
}
<div id="main">
<div class="child">One</div>
<div class="child">Two</div>
</div>

Angular Material way of making a horizontal line with word in the middle

Using Angular Material, I'm trying to create a horizontal line with a word in the middle. Something pretty similar to the one displayed here.
I've tried this and it's close but I'd like the lines to be vertically aligned to the middle of the word or.
<div layout="row" layout-align="center start">
<md-divider flex></md-divider>
<div style="flex: 0 1 auto;">or</div>
<md-divider flex></md-divider>
</div>
http://jsfiddle.net/devotis/a7m6xrwy/
I guess, I need styled <hr>'s left and right. How can I improve this code and remain within the ways of Angular Material?
A nice way to do it is to use the layout="row" along with flex.
<span layout="row"><hr flex/>or<hr flex/></span>
JS fiddle applying this idea to the button text: http://jsfiddle.net/a7m6xrwy/1/
You can style the hr attribute with css. The md-divider directive isn't meant to be used this way, so there is no reason to try and force it. If you wish to use a directive to solve this issue, you will have to write your own md-divider directive which takes the display text as a parameter.
Here is a solution using material's mat-divider:
<h1>Divider with text</h1>
<div class="container">
<div class="line"><mat-divider></mat-divider></div>
<div class="text mat-typography">Hey there</div>
<div class="line"><mat-divider></mat-divider></div>
</div>
.container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.line {
flex: 1;
}
.text {
padding-left: 10px;
padding-right: 10px;
}
The result will look like this:
For people using angular material 2 and flex-layout, here's my solution. Not entirely satisfactory, but it does the trick.
<div fxLayout="row" fxLayoutAlign="space-between center" fxLayoutGap="5px">
<mat-divider fxFlex="1 0"></mat-divider>
<div>or</div>
<mat-divider fxFlex="1 0"></mat-divider>
</div>
This would work like a charm.
<mat-divider style="width: 40%; display: inline-block;"></mat-divider>
<span style="padding: 20px; font-weight: 500;">Or</span>
<mat-divider style="width: 40%; display: inline-block;"></mat-divider>
PS: You may extract the inline styles into meaningful CSS classes. Avoided it here for brevity.
Output:

Resources