I know this has been answered here but for I cannot get my image to alternate. I am using Vuetify but overwriting certain styles so I think that might have something to do with it.
I have tried using both flex-flow: row-reverse; and float: right/left but without any luck..
Can anyone see an obvious error I am missing?
<template>
<v-card class="mx-auto mt-5 posts-list-item" outlined>
<v-container class="posts-list-item__content">
<v-card flat class="posts-list-item__container posts-list-item__image">
<v-img
class="pa-2 posts-list-item__img"
src="https://picsum.photos/510/300?random"
></v-img>
</v-card>
<v-card
flat
class="posts-list-item__container posts-list-item__description"
>
<v-card-title class="mb-4 posts-list-item__title">{{
post.title
}}</v-card-title>
<v-card-subtitle class="posts-list-item__subtitle">
{{ post.content }}
</v-card-subtitle>
</v-card>
</v-container>
</v-card>
</template>
<style lang="scss">
.posts-list-item {
&__content {
display: flex;
}
&__container {
&:nth-of-type(odd) {
float: left;
}
&:nth-of-type(even) {
float: right;
}
}
&__image {
width: 33%;
}
&__description {
width: 66%;
display: flex;
flex-direction: column;
align-content: stretch;
}
I had to step down from the parent and apply flex-direction: row-reverse
.posts-list {
&:nth-child(even) > .posts-list-item > .posts-list-item__content {
flex-direction: row-reverse;
}
}
Related
I have a two basic div containers and I am trying to apply some styles to it. I do import my CSS styles from a separate .module.css file and the first style gets picked up in the className property, when assigned. However, the same thing is not working for the second div. The css property for class 'sales' is not being picked up
dashboard.js
import HomeSalesmanStyles from '../../../styles/SalesmanHome.module.css';
const HomeSalesman = ({name}) => {
return(
<>
<div className={HomeSalesmanStyles.container}>
<h4>
Hello, {name} 👋
</h4>
</div>
<div className={HomeSalesmanStyles.sales}>
Hello
</div>
</>
)
};
export default HomeSalesman;
SalesmanHome.module.css
.container {
display: flex;
justify-content: center;
margin-top: 5%;
};
.sales {
display: flex;
justify-content: center;
width: 100px;
background-color: red;
}
Any ideas where the issue is?
----------- Edit ------------
The issue was wrong css module name import! After correcting to the right file, everything works.
This looks like a syntax error in the CSS: adding a semicolon after a rule is invalid.
.container {
display: flex;
justify-content: center;
margin-top: 5%;
} /* <- no semicolon */
.sales {
display: flex;
justify-content: center;
width: 100px;
background-color: red;
}
<div class="container">
<h4>
Hello, {name} 👋
</h4>
</div>
<div class="sales">
Hello
</div>
<mat-card-header>
<mat-card-title>Shiba Inu</mat-card-title>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-subtitle>Dog Breed</mat-card-subtitle>
</mat-card-header>
This places the mat-card-avatar on the left, are there any configuration in the mat-card-header that allow to move the avatar to the right end of the header
you can try this:
::ng-deep .mat-card-header{
flex-direction: row-reverse !important;
}
::ng-deep .mat-card-avatar{
width: 10%;
}
::ng-deep .mat-card-header-text{
width: 90%;
}
There is no official way because if you see their source code for mat-card-header They place avatar first and then text.
<ng-content select="[mat-card-avatar], [matCardAvatar]"></ng-content>
<div class="mat-card-header-text">...</div>
<ng-content></ng-content>
You have to override styles manually. Since it is a flexbox you can override it easily without changing HTML like this.
<mat-card-header class="mat-card-header-avatar-right">
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>Shiba Inu</mat-card-title>
<mat-card-subtitle>Dog Breed</mat-card-subtitle>
</mat-card-header>
//SCSS Version
.mat-card-header-avatar-right {
justify-content: space-between;
&::ng-deep {
.mat-card-header-text {
margin-left: 0 !important;
}
}
.mat-card-avatar {
order: 1;
}
}
//CSS Version
.mat-card-header-avatar-right {
justify-content: space-between;
}
.mat-card-header-avatar-right ::ng-deep .mat-card-header-text {
margin-left: 0 !important;
}
.mat-card-header-avatar-right .mat-card-avatar {
order: 1;
}
I want to use horizontal scroll with left and right arrows with dynamically hide and show functionality.
Horizontal scroll (with arrows) for Angular package This thread here answers it but without dynamic hide/show of arrows. Please reply if someone has idea about it. Thanks.
Here is the code below:
.html
<div class="custom-slider-arrow mt-sm">
<img src="assets/img/chevron-left.svg" alt="" (click)="scrollLeft()">
</div>
<div #widgetsContent class="custom-slider-main">
<ng-container *ngFor="let object of statusList">
<status-card ></status-card>
</ng-container>
</div>
<div class="custom-slider-arrow mt-sm">
<img src="assets/img/chevron-right.svg" alt="" (click)="scrollRight()">
</div>
</div>
And .ts file has this code.
#ViewChild('widgetsContent',{static:false}) widgetsContent: ElementRef;
scrollLeft(){
this.widgetsContent.nativeElement.scrollLeft -= 300;
}
scrollRight(){
this.widgetsContent.nativeElement.scrollLeft += 300;
}
.scss file contains
.custom-slider-main{
display: flex;
overflow: hidden;
scroll-behavior: smooth;
}
.custom-slider-arrow{
display: flex;
align-items: center;
img{
width: 48px;
height: 48px;
}
}
1) .ts file
import { Component, OnInit, ViewChild, ElementRef } from '#angular/core';
export class Scroll implements OnInit {
#ViewChild('scrollMenu') scrollMenu: ElementRef;
rightDisabled: boolean = false;
leftDisabled: boolean = true;
constructor(){}
scrollLeft(){
this.scrollMenu.nativeElement.scrollLeft -= 150;
this.checkScroll()
}
scrollRight(){
this.scrollMenu.nativeElement.scrollLeft += 150;
this.checkScroll();
}
onScroll(e){
this.checkScroll();
}
checkScroll(){
this.scrollMenu.nativeElement.scrollLeft==0? this.leftDisabled = true :this.leftDisabled = false;
let newScrollLeft = this.scrollMenu.nativeElement.scrollLeft;
let width = this.scrollMenu.nativeElement.clientWidth;
let scrollWidth = this.scrollMenu.nativeElement.scrollWidth;
scrollWidth - (newScrollLeft+width)==0? this.rightDisabled = true :this.rightDisabled = false;
}
}
2) .html file
<ion-row>
<div class="pull-left mt-sm" (click)="scrollLeft()" [ngClass]="this.leftDisabled ? 'visibility':''">
<ion-icon name="chevron-back-outline" style="font-size: 24px;" ></ion-icon>
</div>
<div class="scroll" scrollX="true" #scrollMenu (scroll)="onScroll($event)" [ngClass]="this.rightDisabled ? 'width':this.leftDisabled?'width':''">
<div *ngFor="let data of yourDataArray">
{{data.someData}}
</div>
</div>
<div class="pull-right" (click)="scrollRight()" [ngClass]="this.rightDisabled ? 'visibility':''">
<ion-icon name="chevron-forward" style="font-size: 24px;" ></ion-icon>
</div></ion-row>
3) .scss file
.scroll {
overflow: auto;
scroll-behavior: smooth;
width: 80%;
background: var(--ion-primary-bg);
}
.pull-right{
background: grey;
display: flex;
align-items: center;
width: 10%;
justify-content: space-around;
}
.visibility{
display: none !important;
}
.pull-left{
background: grey;
display: flex;
align-items: center;
width: 10%;
justify-content: space-around;
}
.width{
width:90% !important;
}
I import the styles to the component like below. Up: It's a React component with a postcss-loader in Webpack.
import styles from './index.scss';
This is a gist from the component:
<div className={styles['container']}>
<Row type='flex' align='middle' justify='space-between'>
<Col span={24}>
... ...
</Col>
</Row>
</div>
This is the styles:
.container {
margin-left: 24px;
& .ant-row-flex.ant-row-flex-space-between.ant-row-flex-middle {
height: 100%;
display: flex;
& .ant-col-24 {
display: flex;
align-items: center;
}
}
}
Only the .container's margin-left: 24px; gets displayed in the component.
How to get .ant-row-flex.ant-row-flex-space-between.ant-row-flex-middle from Row and .ant-col-24 from Col to display too?
Here is my html markup:
<div class="expander-container" data-css="expander-container">
<div class="top-comment-container" data-css="top-comment-container">
<a class="expand-anchor" data-css="expand-anchor" >
<div><span class="alternate-color icon-next arrow"
data-css="alternate-color icon-next _2Cx2VFM04V1vDEfkDEJ3Cw" ></span></div>
<div class="activity-item activity-container"
data-css="activity-item" >
<div class="activity-text" data-css="activity-text" ><span >Content</span></div>
<div class="activity-vote-count" data-css="activity-vote-count" ><span >0</span><span> vote</span></div>
<div class="activity-reply-count"
data-css="activity-reply-count" ><span>1</span><span> reply</span></div>
<time datetime="Wed May 25 2016 15:57:21">
<span >May 25, 2016, 3:57 PM</span></time></div>
</a>
</div>
</div>
Here is my css (in less)
.expander-container {
display: flex;
flex-direction: column;
}
.expand-anchor {
background: none;
border: none;
padding: 0;
cursor: pointer;
align-self: center;
&:hover {
text-decoration: none;
}
}
.icon-next:before {
content: ">";
}
.arrow:before {
display: inline-block;
transform: rotate(0deg);
transition: transform .25s ease-out;
.expand& {
transform: rotate(90deg);
}
}
.top-comment-container {
display: flex;
flex-direction: row;
align-items: flex-start;
border: 1px solid green;
flex-wrap: nowrap;
}
.reply-container {
display: flex;
}
// activity-item
.activity-item {
margin-left: 5px;
}
.reply-item {
margin-left: 10px;
border: 1px solid blue;
}
.activity-container {
display: flex;
}
.activity-text {
align-self: center;
flex-grow: 1;
flex: 5;
// flex-basis: 100;
}
.activity-vote-count {
align-self: center;
// width: 10%;
flex: 1;
}
.activity-reply-count {
align-self: flex-end;
// flex-basis: 1;
// width: 10%;
flex: 1;
}
.activity-container {
align-self: center;
}
What I want to achieve is to have all these elements aligned on a single axis.
e.g.
> Content 0 vote 1 reply May 25, 2016, 3:57 PM
However as you can see in my codepen coode (http://codepen.io/kongakong/pen/YWKvgG?editors=1100), the arrow somehow occupies one line by itself. The rest of content is squeezed to the next line.
I have tried a few thing e.g. add flex-basis, flex-wrap: nowrap etc but they do not have any effect.
A second question is how can I have finer control on the placement? I want the text 'Content' to occupy most of the space in a row. Information such as vote and time should be moved to the right hand side. I have applied the 'flex-grow:1' to the text but it does not grow and fill the space.
Flex row works by aligning its immediate children in a row. You have your elements nested too deeply. Everything you want on the same row needs to be siblings. You can see some work I've done with flex for reference http://codepen.io/steezeburger/pen/LNEaKv
<div class="flex-row">
<div class="wrapper">
<div class="flex-column skinny">
<span class="flex-vertical-center af af-icon" data-bind="css: action_color">
<i class="fa fa-check"></i>
</span>
</div>
<div class="flex-column">
<span class="af af-action">New Order</span>
<span class="af af-name">John Carmack</span>
</div>
</div>
<div class="flex-column">
<span class="af af-time-lapsed">13m ago</span>
<span class="af af-value">$65</span>
</div>
</div>
This is a bit more advanced as I have nested columns in my rows, but you can see above that .wrapper and the last .flex-column div will be on the same row. Check out the codepen for a clearer example.
try this code
<style>
.top-comment-container {
width: 40em;
}
.alternate-color {
display: inline-block;
}
.activity-item {
display: flex;
justify-content: space-between;
}
.abcd {
display: flex;
}
</style>
</head>
<body>
<div class="expander-container" data-css="expander-container">
<div class="top-comment-container" data-css="top-comment-container">
<a class="expand-anchor" data-css="expand-anchor">
<div><span class="alternate-color icon-next arrow" data-css="alternate-color icon-next _2Cx2VFM04V1vDEfkDEJ3Cw"></span></div>
<div class="activity-item activity-container" data-css="activity-item">
<div class="activity-text" data-css="activity-text"><span>Content</span></div>
<div class="abcd">
<div class="activity-vote-count" data-css="activity-vote-count"><span>0</span><span> vote</span></div>
<div class="activity-reply-count" data-css="activity-reply-count"><span>1</span><span> reply</span></div>
<time datetime="Wed May 25 2016 15:57:21">
<span>May 25, 2016, 3:57 PM</span>
</time>
</div>
</div>
</a>
</div>
</div>
</body>
apply margins as you like..