How to set lists in one row in Angular - html

I have a list of items, I want to make them be inline, have tried css but I dnt think am cracking it, they end up being set in the number of lines I have the items in the list,
This is my css
.list-list-item li{
position: relative;
display: block;
padding: .75rem 1.25rem;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid rgba(0, 0, 0, .125)
}
.list-list {
display: -ms-flexbox;
display: inline-block !important;
-ms-flex-direction: column;
flex-direction: column;
padding-left: 0;
margin-bottom: 0
}
This is my html
<ul class="list-list ">
<li class="list-list-item"
style="font-size: 2em;font-weight: bold; color: white;text-align: left;">
{{reports.response_rate | number : '1.2-2'}} % Rate
</li>
<li class="list-list-item" style="vertical-align:bottom; text-align:left; font-size: 2em;font-weight: bold;color:white"
[ngStyle]="{'color' : (reports.response_rate_7day_change > 0) ? 'green': 'red'}">
{{reports.response_rate_7day_change | number : '1.4-4'}}
</li>
<li class="list-list-item" style="font-size: 2em;font-weight: bold; color: white;text-align: left;"
[ngStyle]="{'background-image' : (reports.response_rate_7day_change > 0) ? getIncrease(): getDecrease() }"
style="background-repeat: no-repeat">
</li>
</ul>
this is what I end up with, how can I have them in one line?

You have several problems in your css code.
Wrong selector: .list-list-item li doesn't select anything. li already is .list-list-item
A bit of mess on the .list-list selector - you target different types of display values, plus flex-direction: column; does nothing on display: inline-block
At any rate, setting flex-direction: column; will not help in having the children displayed inline :) row will.
I have removed anything that is irrelevant to the problem:
html
<ul class="list-list ">
<li class="list-list-item">
20% Rate
</li>
<li class="list-list-item">
abc
</li>
<li class="list-list-item">
abc
</li>
</ul>
css
.list-list {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
}
.list-list-item {
list-style: none;
}

Related

HTML and CSS table/grid design

I was trying to design table below. I tried to use a HTML table but I couldn't get the box shadow to apply properly as I had to round the corners of the first and last td cells and not the tr (as it doesn't support a border radius) but then applying a box shadow to the row didn't go round the curved edges, rather it stayed square.
I also tried display:grid & flex, however, I could find a way to get the box-shadow/border-radius and centre align the text within columns, it was a trade off.
So any advice would be much appreciated.
This is what I was trying to convert to HTML and CSS.
This is the react code is use to render the HTML for the table:
<div className="policy-container">
<div className="policy-table">
<div className="headings">
<span className="heading">Name</span>
<span className="heading">Last Updated</span>
<span className="heading">Actions</span>
</div>
{data.map((row, ri) => (
<div key={ri} className="policy">
<span>{row.name}</span>
<span>{row.lastUpdated.format("Do MMM YYYY")}</span>
<span>
<a href={row.link}>view</a>
</span>
</div>
))}
</div>
</div>
I would do something like this, using flex:
body {
background-color: #eefbfb;
font-family: sans-serif;
font-size: 16px;
}
.policy-table {
color: grey;
text-align: center;
}
.headings, .policy {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
margin-bottom: 1em;
padding: 1em;
}
.heading {
flex-basis: 33.333%;
font-weight: bold;
}
.policy {
border-radius: 2em;
background-color: white;
margin-bottom: 20px;
-moz-box-shadow: 0 0 3px grey;
-webkit-box-shadow: 0 0 3px grey;
box-shadow: 0 0 5px grey;
}
span {
flex-basis: 33.333%;
}
a {
text-decoration: none;
color: #4c4c4c;
}
<div class="policy-container">
<div class="policy-table">
<div class="headings">
<span class="heading">Name</span>
<span class="heading">Last Updated</span>
<span class="heading">Actions</span>
</div>
<div class="policy">
<span>Name</span>
<span>DD MM YY</span>
<span>
<a href={row.link}>view</a>
</span>
</div>
<div class="policy">
<span>Name</span>
<span>DD MM YY</span>
<span>
<a href={row.link}>view</a>
</span>
</div>
</div>
</div>

How to fix mat-list-item not taking full space of row

Hello guys I rendering an article.component.html inside my article-list-component.html in a list when I do it in plain HTML it renders just fine (see picture 1):
Title - author - Date
Here is my article-list.component.html
<ul>
<li *ngFor="let article of data_array">
<a [href]="article.url" class="undecorateda" target="_blank">
<app-article [data]='article'></app-article>
</a>
</li>
</ul>
but when I try to use angular-material list the component renders all to the left like this (see picture 2):
Title-author-Date
Here is my article-list.component html:
<mat-list>
<mat-list-item *ngFor="let article of data_array">
<a [href]="test">
<app-article [data]='article' (click)="printURL(article.url)"></app-article>
</a>
</mat-list-item>
</mat-list>
when I use the plain HTML in the article-list.component.html it renders as I want it to do, but if I use the material code inside article-list.component.html it doesn't render properly
this is the article.component.html
<div class='article-container'>
<div class='title-container'>
{{data.title}}
<div class='author-container'>
-{{data.author}}-
</div>
</div>
<div class='date-container'>
{{formatDay(data.created_at)}}
</div>
<div class="actions-container" id="deletebtn">
<button mat-icon-button color="warn" (click)="deleteArticle(data._id)">
<mat-icon>delete_forever</mat-icon>
</button>
</div>
</div>
this is the article.component.css file:
.article-container {
display: grid;
grid-auto-flow: column;
grid-template-columns: 10fr 2fr 1fr;
height: 50px;
background-color: #fff;
border-bottom: 1px solid #ccc;
align-items: center;
padding: 0 15px;
}
.article-container>* {
grid-row: 1/2;
}
.article-container #deletebtn {
display: none;
}
.article-container:hover {
background-color: #fafafa;
}
.article-container:hover #deletebtn {
display: block;
}
.title-container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
color: #333;
font-size: 13pt;
}
.author-container {
color: #999;
font-size: 10pt;
margin-top: 3px;
}
.date-container {
color: #333;
font-size: 13pt;
}
.title-container div {
padding: 0 15px;
}
Basically what I want is to use material-angular list inside the article-list.component.html and that it render good like in picture 1
==========================================
If you add a width of 100% to the article component itself it should ensure the component takes the whole width and the list will the whole width as well.
:host {
width: 100%;
}
Take a look at this example here to see the list taking 100% of the width.

show image at mouseover

I'm trying to learn HTML/CSS better, and I'm trying to modify an existing template (https://github.com/codrops/AnimatedGridLayout).
The template has a grid layout, and I'm trying to make it so that when a grid item is moused over, it changes to show an image.
In the HTML, the code looks like this:
<a class="grid__item" href="#">
<h2 class="title title--preview">Demo</h2>
<div class="loader"></div>
<span class="category">Love & Hate</span>
<div class="meta meta--preview">
<img class="meta__avatar" src="img/authors/2.png" alt="author02" />
<span class="meta__date"><i class="fa fa-calendar-o"></i> 7 Apr</span>
<span class="meta__reading-time"><i class="fa fa-clock-o"></i> 5 min read</span>
</div>
</a>
In the CSS it looks like this:
a:hover, a:focus {
color: #333; outline: none;
}
/* Grid item */
.grid__item {
padding: 45px 55px 30px;
position: relative;
color: inherit;
background: #fff;
min-height: 300px;
cursor: pointer;
text-align: center;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-direction: normal;
-webkit-box-orient: vertical;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-justify-content: center;
justify-content: center;
}
I added the below code to see if I could have an effect at mouseover:
.grid__item:hover {
background-color: yellow;
}
However, this made no change. Was this not the right way to handle a hover?
Any help would be greatly appreciated!
try nesting one parent above to get it right...instead of !important try nesting one more parent class make it priority high
section.grid .grid_item:hover {
background-color: yellow;
}
Add This code to css/style2.css
a.grid__item:hover {
background: red;
}
if this not working try
a.grid__item:hover {
background: red !important;
}
if this still not working try clearing your browser cache CTRL + SHIFT + DEL this works for almost every browser on windows

Styling list elements with Flexbox

Please help me. I need 3 li element like in image those I downloaded (icon+text), but they have wrong behavior.
I need like this
.icon-equipment {
background-image: url('http://infocem.info/wp-content/uploads/2017/05/1.png');
background-position: left center;
background-repeat: no-repeat;
padding-left: 20px; /* Adjust according to image size to push text across. */
}
ul {
list-style: none;
}
.advantages {
display: flex;
flex-flow: row wrap;
border: 1px solid purple;
height: 123px;
margin: 0;
padding: 0;
}
.advantages > * {
margin-left: 92px;
}
<ul class="advantages">
<li class="icon-equipment">Поставка оборудования<br> и запчастей<br><span>От 11 ведущих производителей</span><li>
<li class="icon-payment">Рассрочка платежа<br><span>До 45 дней с оформления заказа</span></li>
<li class="icon-delivery">Доставка товаров<br><span>Международная и междугородняя<br>в срок до 10 дней</span></li>
</ul>
The main thing to understand here is how to set-up a good hierarchy, so that you may have control over it. What I mean is, you have to separate your item into sections, which can be arranged easily using your model of choice (flexbox in this case).
Just take a look at the html that I have provided, see how it is structured. You have a container, within that container you have two elements, a left-side element (icon) and a right-side element (texts).
Styles are also a thing to notice, you will need some prefixing as well.
Since this is your first time on stackoverflow, I will give you this code ready for use. Usually you have to provide some code that you have been working on, and then seek assisstance for it. Whatever you do, please DO NOT expect this for future problems that you post here on Stack. Read the rules, follow the rules.
html {
font-family: 'Helvetica Neue', Arial, sans-serif;
}
.icon-equipment {
background-image: url('http://infocem.info/wp-content/uploads/2017/05/1.png');
background-position: left center;
background-repeat: no-repeat;
/* Adjust according to image size to push text across. */
}
ul {
list-style: none;
}
.advantages {
display: flex;
flex-flow: row wrap;
margin: 0;
padding: 0;
}
.advantages .advantages-item {
display: flex;
align-items: flex-start;
background: #000;
color: #fff;
padding: 1rem;
max-width: 300px;
margin-right: 1rem;
margin-bottom: 1rem;
}
.advantages .advantages-item:last-of-type {
margin-right: 0;
}
.advantages .advantages-item .item-right {
display: flex;
flex-direction: column;
padding-left: 1rem;
}
.advantages .advantages-item .item-right .right-text {
font-weight: bold;
text-transform: uppercase;
margin: 0;
margin-bottom: 1rem;
}
<ul class="advantages">
<li class="advantages-item">
<div class="item-left">
<div class="top-icon">
<img src="http://infocem.info/wp-content/uploads/2017/05/1.png" alt="" class="icon">
</div>
</div>
<div class="item-right">
<p class="right-text">Поставка оборудования и запчастей</p>
<span>От 11 ведущих производителей</span>
</div>
<li>
<li class="advantages-item">
<div class="item-left">
<div class="top-icon">
<img src="http://infocem.info/wp-content/uploads/2017/05/1.png" alt="" class="icon">
</div>
</div>
<div class="item-right">
<p class="right-text">Поставка оборудования и запчастей</p>
<span>От 11 ведущих производителей</span>
</div>
<li>
<li class="advantages-item">
<div class="item-left">
<div class="top-icon">
<img src="http://infocem.info/wp-content/uploads/2017/05/1.png" alt="" class="icon">
</div>
</div>
<div class="item-right">
<p class="right-text">Поставка оборудования и запчастей</p>
<span>От 11 ведущих производителей</span>
</div>
<li>
</ul>

Difficulty getting a full width display

I am working on a Joomla 2.5 based English-Thai website. There is a menu item in Thai in a hidden menu. This menu item is starred and so when the website is accessed, the Thai page is displayed. There is also an similar menu item in English. The two pages can be accessed one from the other by buttons.
As can be seen in the images, while the Thai page displays full width, the English page does not. The problem seems to be dependent on starring, since swapping the starring over to the English menu item results in the English page being displayed full width, and the Thai page narrowed
I've looked thru the Joomla backend for any clues as to why this is happening, but I can't see any. Any help would be much appreciated.
EDIT
Here is part of the markup and CSS for the 2 pages
HTML - Thai page
<div id="front_page">​
<div><span id="btn_text">english</span></div>
<div id="fp_container">
<!-- flex container -->
<div id="fp_logo">
<!-- first flex item containing the e2tw logo -->
<img class="fpm_image" src="/templates/beez_20/images/e2tw/e2tw_logo1.svg" />
<p class="fp_content1">english2theworld</p>
<p class="fp_content2">สำหรับผู้ที่ต้องการเรียนภาษาอังกฤษ</p>
<div class="fp_login"> {loadmodule mod_login}</div>
</div>
<div id="intro_container1">
<div id="intro_outliner">
<div id="intro_item1" class="intro_items intro_item_1 intro_item_eng">
<p id="intro_head1" class="intro_content fp_heading"><span class="intro_head_title">เชิญเข้าสู่ โปรแกรม <span class="e2tw_text">english2theworld</span></span></p>
<ul class="fp_lists fa-ul icon-star">
<li class="fp_list_text ">โปรแกรม english2theworld เป็นการวางรากฐานด้วยการสอนภาษาอังกฤษด้วยการฝึกหัดที่นำสมัย</li>
<li class="fp_list_text ">english2theworld นำสมัยในด้านการสื่อสารด้วยเทคโนโลยีที่ช่วยให้นักเรียนเรียนรู้ในการพูด การอ่านและการเขียนภาษาอังกฤษเป็นไปได้โดยเห็นผลอย่างรวดเร็วและมีประสิทธิภาพ</li>
</ul>
</div>
<!-- markup deleted here similar to the abaove -->
</div>
</div>
</div>
</div>
HTML - English page
<div id="front_page">​
<div><span id="btn_text">อังกฤษ</span></div>
<div id="fp_container">
<!-- flex container -->
<div id="fp_logo">
<!-- first flex item containing the e2tw logo -->
<img class="fpm_image" src="/templates/beez_20/images/e2tw/e2tw_logo1.svg" />
<p class="fp_content1">english2theworld</p>
<p class="fp_content2">for all who want to learn English</p>
<div class="fp_login"> {loadmodule mod_login}</div>
</div>
<div id="intro_container1">
<div id="intro_outliner">
<div id="intro_item1" class="intro_items intro_item_1 intro_item_eng">
<p id="intro_head1" class="intro_content fp_heading"><span class="intro_head_title">WELCOME T0 <span class="e2tw_text">english2theworld</span></span></p>
<ul class="fp_lists fa-ul icon-star">
<li class="fp_list_text ">english2theworld is based on sound teaching practice</li>
<li class="fp_list_text ">english2theworld uses interactive web technology to help students learn to speak, read and write English as quickly and efficiently as possible</li>
</ul>
<!-- markup deleted here similar to the abaove -->
</div>
</div>
</div>
</div>
CSS
div#fp_container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-content: stretch;
align-items: flex-start;
padding-bottom: 1%;
}
div#fp_logo {
order: 0;
flex: 1 1 auto;
align-self: auto;
width: 35%;
border: 1px solid #000093;
margin: 0 0 0 4%;
background: #EFF1FF;
}
div#fp_logo img.fpm_image {
width: 70%;
height: auto;
margin: auto auto;
display: block;
margin-top: 5%;
}
p.fp_content1, p.fp_content2 {
font-family: 'Baumans', cursive;
font-weight: 600;
color: #000093;
text-align: center;
}
p.fp_content1 {
font-size: 1.9em;
margin: 1% 0 1% 0;
}
p.fp_content2 {
font-size: 1.4em;
margin: 0 0 1% 0;
}
div.fp_login {
margin: 10% 2% 5% 2%;
}
div.fp_login fieldset.userdata ul {
margin: 0;
}
div.fp_login li {
font-size: 0.5em;
}
div#intro_container1 {
flex: 2 1 auto;
display: flex;
flex-flow: column wrap;
// justify-content: flex-start;
// align-content: center;
//align-items: baseline;
// margin: 2% 5% 5% 2%;
width: 95%;
}
div.intro_outliner {
border: 1px solid #000093;
}
div#intro_item1, div#intro_item2, div#intro_item3,
div#intro_item4, div#intro_item5 {
order: 0;
flex: 0 1 90%;
width: 87%;
margin: 0 0 2% 5%;
background: #EFF1FF;
}
I hope this helps. Thank you for your interest.