show image at mouseover - html

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

Related

How to set lists in one row in Angular

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;
}

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.

(SCSS) My media queries aren't working correctly with display: flex;

I'm working with SCSS trying to create a responsive site. I'm using Koala to compile my code, and I have a styles.scss that is importing my other partial stylesheets. Certain styles do work dynamically on my site when changing the width, but with my display: flex; things aren't changing to what I want them to.
I've tried changing the media queries to nest inside of themselves, but nothing is working properly.
styles.scss
#import "reset";
#import "variables";
// #media only screen and (min-width: 1em) {
#import "small-default";
// }
//35em is also 560px (if basefont is 16px)
#media only screen and (min-width: 560px) {
#import "medium";
}
//64em is also 1028px (if basefont is 16px)
#media only screen and (min-width: 1028px) {
#import "large";
}
index.html
<div class="footer">
<footer>
<div class="info">
<div class="contact">
<h2>Contact Us</h2>
<p>CABOT CRUIZES</p>
<p>23 South Main St. Suite 16</p>
<p>Lexington, VA 24450</p>
<br>
<h2>Phone:</h2>
<p>1-800-555-1234</p>
<br>
<h2>Hours of Operation:</h2>
<p>Monday - Friday 9am - 4pm</p>
</div>
<div class="newsletter">
<h2>News Letter</h2>
<p>Subscribe to our email list and stay up-to-date with our hottest offers and latest specials.</p>
<div class="subscribe">
<input type="email" name="" id="subscribeEmail">
<button type="submit">Subscribe</button>
</div>
</div>
</div>
<div class="why">
<h2>Why Cabot Cruises?</h2>
<p>Cabot Cruises is a travel agency providing the best cruise deals on our online travel website. We can help you with all inclusive vacations including discounted cruises.</p>
<br>
<p>We do not sell travel to residents of Deleware, Iowa, Florida, Hawaii and Washington state because those states are just wierd. If you are a resident of one of these states, call your congressman and tell them to change the regulations. </p>
</div>
</footer>
</div>
_small-default.scss
.footer {
background-color: $secondaryColor;
footer {
max-width: 1024px;
margin: 0 $gutter;
padding: 1rem 0;
color: $thirdColor;
.info {
margin: 0 auto;
color: $thirdColor;
display: flex;
flex-direction: column;
.contact, .newsletter, .why {
padding: .5rem 0;
}
.contact {
}
.newsletter {
display: flex;
flex-direction: column;
justify-content: center;
.subscribe {
display: flex;
flex-direction: column;
justify-content: center;
input{
height: 35px;
margin-bottom: .2rem;
}
button {
height: 44px;
background-color: #666;
border-radius: 10px;
color: #fff;
}
}
}
.why {
}
h2{
margin-bottom: .75rem;
}
input {
margin-top: .6rem;
}
}
}
}
_medium.scss
(I'm just trying to do a simple direction change to the layout, but nothing is working.)
footer {
.info {
flex-direction: row;
}
}
would be
.footer {
footer {
.info {
flex-direction: row;
}
}
}
or
.footer footer .info {
flex-direction: row;
}
if you would like to call it the same way you did in your medium.scss

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>