Ionic list: How to edit the style of the list items? - ionic-framework

I used the following code inside my side menu:
<ion-side-menu side="left">
<ion-content>
<div class="list">
<a class="item" menu-close href="#/app/products">
<img src="img/home.png" width="30px" />
<!-- <i class="icon ion-home"></i> -->
<h2>YourPhoto24</h2>
</a>
<a class="item" menu-close href="#/app/account">
<img src="img/profile.png" width="30px" />
<h2>mein Konto</h2>
</a>
<a class="item" menu-close href="#/app/orders">
<img src="img/orders.png" width="30px" />
<h2>meine Bestellungen</h2>
</a>
<a class="item" menu-close href="#/app/receivers">
<img src="img/receivers.png" width="30px" />
<h2>meine Empfänger</h2>
</a>
<a class="item" menu-close href="#/app/email">
<img src="img/email.png" width="30px" />
<h2>Email an uns</h2>
</a>
<a class="item" menu-close href="#/app/recommend">
<img src="img/recommend.png" width="30px" />
<h2>Empfehlen Sie uns weiter
<p>mein Guthaben beträgt zur Zeit: </p>
</h2>
</a>
<a class="item" menu-close href="#/app/siteNotice">
<img src="img/laws.png" width="30px" />
<h2>AGB & Impressung</h2>
</a>
</div>
</ion-content>
</ion-side-menu>
So i wanted an icon at the left and the text to the right centered vertically. Unfortunately i did not get the result i expected:
1: How can i manage to get more space between the image and the text and how can i vertically center the text?
2: How can i hide the dividers?
3: How can i increase the top and bottom padding of the list items? I want them to be 40px.
I added the following to my css file:
.menu.menu-left, .list a {
border-color: transparent;
padding-top: 30px;
padding-bottom: 30px;
}
.menu.menu-left, .list img {
float: left;
vertical-align: middle;
}
.menu.menu-left, .list h2 {
display: inline-block;
}
The padding and the hiding of the divider works with that code. but i cant manage to pretty align the text next to the image centered vertically (both should be centered vertically, the image and the text!)
So whats left is: How can i manage to get more space between the image and the text and how can i vertically center the text?

Ionic already provides a lot to do something like this with stylings they already made. Take a look at this example in their docs.:
<div class="list">
<a class="item item-icon-left" href="#">
<i class="icon ion-person"></i>
mein Konto
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-navicon-round"></i>
meine Bestellungen
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-heart"></i>
meine Empfänger
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-email"></i>
Email an uns
</a>
<a class="item item-icon-left" href="#">
<i class="icon ion-android-share-alt"></i>
Empfehlen Sie uns weiter
</a>
</div>
Here is a little codepen to demonstrate what you want:
http://codepen.io/anon/pen/ZGBegG

Related

Cannot get ngx-infinite-scroll to listen to window scroll

I am trying to implement ngx-infinite-scroll
I am unable to get it to do what I want which is listen to my browser or window scroll so I may scroll content and load when needed.
What's happening is can implement this library ONLY when I set the scroll to listen to some other div so the result is two scroll bars (1) browser window scroll bar (2) content div scroll bar - this is not desirable and creates a real messy UX.
You will notice a setting in the template "scrollWindow" I have tried changing this value without any success I'm not too sure what i'm doing wrong here...
Environment
Angular 8 with Angular Material
Template and Styling:
.container {
height: 100vh;
width: 70vw;
font-family: Arial, Helvetica, sans-serif;
padding-top: 20px;
overflow-y: auto;
}
HTML
<app-navigation-bar></app-navigation-bar>
<app-userpost></app-userpost>
<div *ngIf="loading">
<app-progress-spinner></app-progress-spinner>
</div>
<!-- infinite scroll div -->
<div
class="container"
infiniteScroll
[infiniteScrollContainer]="container"
[scrollWindow]="false"
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="5"
[infiniteScrollThrottle]="300"
(scrolled)="onScrollDown()"
>
<mat-card *ngFor="let post of postObjects">
<mat-card-header>
<img mat-card-avatar src={{post.profile_picture}} alt="no profile image">
<mat-card-title>{{post.email}}</mat-card-title>
<mat-card-subtitle> {{post.upload_date | date:"medium"}} </mat-card-subtitle>
</mat-card-header>
<img mat-card-image src={{post.photo}}>
<mat-card-content>
<p>
{{post.author_comment}}
</p>
</mat-card-content>
<!-- This fills the remaining space of the current row -->
<mat-card-actions class="action-buttons">
<button mat-button color="primary" (click)="post_like(post.post_id)">
<mat-icon>thumb_up_alt</mat-icon> {{post?.post_likes?.length}} Likes
</button>
<button mat-button color="primary" (click)="post_dislike(post.post_id)">
<mat-icon>thumb_down</mat-icon> {{post?.post_dislikes?.length}} Dislikes
</button>
<button mat-button color="primary">
<mat-icon>share</mat-icon> Share
</button>
<a mat-button color="primary" target="_blank">
<mat-icon>visibility</mat-icon> View
</a>
</mat-card-actions>
<mat-accordion>
<div *ngIf="post?.post_comments?.length > 0">
<mat-expansion-panel>
<mat-expansion-panel-header>
<div class="comment-header">
<span class="label label-primary">{{post?.post_comments?.length}} Comments</span>
</div>
</mat-expansion-panel-header>
<mat-list>
<div *ngIf="post?.post_comments?.length > 0">
<div *ngFor="let postSection of post.post_comments; let i = index">
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header collapsedHeight="80px" expandedHeight="30px">
<mat-panel-title>
<div style="max-height: 53px; text-overflow: ellipsis">
<img mat-card-avatar
src="https://source.unsplash.com/random/200x200"
style="padding: 5px">
<strong
style="padding: 5px">{{postSection?.comment_author}}</strong>
<small style="padding: 5px">
{{postSection?.date | date:"medium"}}</small>
</div>
</mat-panel-title>
</mat-expansion-panel-header>
<hr>
<p>{{postSection?.post_comment}}</p>
</mat-expansion-panel>
</mat-accordion>
</div>
</div>
</mat-list>
</mat-expansion-panel>
</div>
</mat-accordion>
<form [formGroup]="PostComment">
<div class="input-group">
<div id="container">
<div id="profile_img">
<div class="actions">
<div class="avatar">
<img class="d-flex mr-3 rounded-circle" src={{userAvatar}} alt="Cannot Load Photo"
width="30" height="30">
</div>
</div>
</div>
<mat-form-field class="example-full-width" style="margin-top: 10px;">
<textarea matInput formControlName="post_comment" #message maxlength="500"
placeholder="Leave a comment"></textarea>
<mat-hint align="start">
<strong>Say something constructive..</strong>
</mat-hint>
<mat-hint align="end">{{message.value.length}} / 500</mat-hint>
</mat-form-field>
<div class="post-button">
<button mat-raised-button (click)="createComment(post.post_id)">Post</button>
</div>
</div>
</div>
</form>
</mat-card>
<div *ngIf="end_of_data">
<strong><h3>No More Data To Load..</h3></strong>
</div>
</div>
change this [infiniteScrollContainer]="container" by [infiniteScrollContainer]="'.container'"

Bootstrap Horizontal Navbar Toggle

I prepared simple navbar menu with BS 4 documents. The toggle menu displays vertical when I clicked. Is it possible make horizontal with BS?
This is my navbar and codepen.io: vertical toggle
body {
margin: 0 auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="nav-brand" href="#">
<img class="img-responsive" src="https://cdn2.iconfinder.com/data/icons/camping-outline-flat-pt-2/100/069_-_snowboard_snowboarding_board_1-128.png" width="55" height="55" alt="logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainNav">
<span class="navbar-toggler-icon"</span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<div class="navbar-nav ml-auto">
<a class="nav-item nav-link active" href="#">ABOUT<span class="sr-only">(current)</span></a>
<a class="nav-item nav-link " href="#">PORTFOLIO</a>
<a class="nav-item nav-link " href="#">CONTACT</a>
</div>
</div>
</nav>
This is as I want but I couldn't figured out with source code: horizontal toggle
It's fairly simple to do that. Bootstrap has flex class options, so there's no need to create your own code.
Simply change:
<div class="navbar-nav ml-auto">
To:
<div class="navbar-nav flex-row ml-md-auto d-md-flex">
Also make sure to add p-2 to your nav-item that will give you some padding space between the elements.
That makes your code look like this:
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="nav-brand" href="#">
<img class="img-responsive" src="https://cdn2.iconfinder.com/data/icons/camping-outline-flat-pt-2/100/069_-_snowboard_snowboarding_board_1-128.png" width="55" height="55" alt="logo">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainNav">
<span class="navbar-toggler-icon"</span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<div class="navbar-nav flex-row ml-md-auto d-md-flex">
<a class="nav-item nav-link p-2 active" href="#">ABOUT<span class="sr-only">(current)</span></a>
<a class="nav-item nav-link p-2" href="#">PORTFOLIO</a>
<a class="nav-item nav-link p-2" href="#">CONTACT</a>
</div>
</div>
</nav>

Bootstrap 4 Beta - Applying a background-image to Jumbotron breaks a Form element

I was creating a bootstrap website as a challenge when I encountered a problem which I can't find a fix for.
In the jumbotron I have a form with a textfield and a submit button.
The textfield also has an addon (input-group-addon)
Without any images The addon is placed perfectly where it should be but When I add an image the Addon moves away a pixel from the text field.
.bg {
background-image: url("http://www.zastavki.com/pictures/originals/2013/Photoshop_Image_of_the_horse_053857_.jpg");
text-align: center;
color: white;
}
.jumbotron form {
text-align: none;
}
.jumbotron hr {
background-color: white;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<body style="position: relative;" data-spy="scroll" data-target="#navBar">
<nav id="navBar" class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">My App</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Download</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="jumbotron bg">
<h1 class="display-3">My Amazing App!</h1>
<p class="lead">The MAIN reason for YOU to download THIS app on your handheld Android or iOS device.</p>
<hr class="my-4">
<p class="lead">Want to learn more ? Join our Mailing List and get a free bonus.</p>
<form class="form-inline justify-content-center">
<label class="sr-only" for="email">Email</label>
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon">#</div>
<input style="width: 350px;" type="email" class="form-control" id="email" placeholder="Your Email">
</div>
<button type="submit" class="btn btn-primary">Sign Up</button>
</form>
</div>
Bootstrap 4, still in beta release, applies a highly-transparent border for the .form-control class. Your example highlights how this may produce unexpected results when using an input element against a container with a dark background. Bootstrap 4's default style is this:
.form-control {
border-color: rgba(0, 0, 0, 0.15);
}
That's a black border with near-maximum transparency. Rendering that over a dark background will not achieve the expected look, as you've discovered.
I've appended a custom class to override Bootstrap 4's default border-color for the .form-control class. Applied to your example, it's in effect only when the class .bg has also been applied to the jumbotron.
.bg .form-control.solid-gray-border {
border-color: rgb(222,222,222);
}
.bg {
background-image: url("http://www.zastavki.com/pictures/originals/2013/Photoshop_Image_of_the_horse_053857_.jpg");
text-align: center;
color: white;
}
.jumbotron form {
text-align: none;
}
.jumbotron hr {
background-color: white;
}
.bg .form-control.solid-gray-border {
border-color: rgb(222,222,222);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<body style="position: relative;" data-spy="scroll" data-target="#navBar">
<nav id="navBar" class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">My App</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Download</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="jumbotron bg">
<h1 class="display-3">My Amazing App!</h1>
<p class="lead">The MAIN reason for YOU to download THIS app on your handheld Android or iOS device.</p>
<hr class="my-4">
<p class="lead">Want to learn more ? Join our Mailing List and get a free bonus.</p>
<form class="form-inline justify-content-center">
<label class="sr-only" for="email">Email</label>
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon">#</div>
<input style="width: 350px;" type="email" class="form-control solid-gray-border" id="email" placeholder="Your Email">
</div>
<button type="submit" class="btn btn-primary">Sign Up</button>
</form>
</div>

Popover in ionic framework

I am trying to create a popup in my ionic view.
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i> Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i> Comment
</a>
<a class="tab-item">
<i class="icon ion-share"></i> Share
</a>
</div>
When i click on Share button , I should get the below template as popup.. not as separate view.
<div class="popover-mask"></div>
<div class="popover popover--down" style="top: 20px; left: 165px;">
<div class="popover__top-arrow"></div>
<div class="popover__content">
<ul class="list">
<li class="item">Facebook
</li>
<li class="item">Twitter
</li>
</ul>
</div>
</div>
How to do it?
Thanks,
Sabarisri
create a share button:
<div class="buttons">
<button class="button button-icon ion-more" ng-click="popover.show($event)"></button>
</div>
put your popover template like this:
<script id="templates/popover.html" type="text/ng-template">
<ion-popover-view>
<ion-content>
<div class="popover-mask"></div>
<div class="popover popover--down" style="top: 20px; left: 165px;">
<div class="popover__top-arrow"></div>
<div class="popover__content">
<ul class="list">
<li class="item">Facebook
</li>
<li class="item">Twitter
</li>
</ul>
</div>
</div>
</ion-content>
</ion-popover-view>
</script>
in your controller call the popover like this:
$ionicPopover.fromTemplateUrl('templates/popover.html', {
scope: $scope,
}).then(function(popover) {
$scope.popover = popover;
});

make the image displayed smaller in ionic

<div class="list card">
<div class="item item avatar item-icon-right">
<img src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<h2>Simran Kaur</h2>
<p>November 06, 1992</p>
</div>
I have this piece of code in ionic and whatsoever image I add here takes up most of the space. Why is that and how do I fix this?
It looks like this:
Here is my complete code:
<div class="list card">
<div class="item item avatar item-icon-right">
<img src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<h2>Simran Kaur</h2>
<p>November 06, 1992</p>
</div>
<div class="item item-body">
<p>
This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
the content is from a card-body consisting of an image and paragraph text. The footer
consists of tabs, icons aligned left, within the card-footer.
</p>
<p>
1 Like
5 Comments
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i>
Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i>
Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>
There is an example of how card should be coded. Avatar is renderd small on the left side, cover is rendered big, and occupy whole space.
Here is codepen with your image rendered both small and big: http://codepen.io/anon/pen/RPvYpp
<div class="list card">
<div class="item item-avatar">
<img src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<h2>Marty McFly</h2>
<p>November 05, 1955</p>
</div>
<div class="item item-body">
<img class="full-image" src="https://pbs.twimg.com/profile_images/598205061232103424/3j5HUXMY.png">
<p>
This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
the content is from a card-body consisting of an image and paragraph text. The footer
consists of tabs, icons aligned left, within the card-footer.
</p>
<p>
1 Like
5 Comments
</p>
</div>
<div class="item tabs tabs-secondary tabs-icon-left">
<a class="tab-item" href="#">
<i class="icon ion-thumbsup"></i>
Like
</a>
<a class="tab-item" href="#">
<i class="icon ion-chatbox"></i>
Comment
</a>
<a class="tab-item" href="#">
<i class="icon ion-share"></i>
Share
</a>
</div>
</div>