Align an ionic button at the bottom right of a div - html

I'd like to place an ionic button at the bottom right of a div. But it doesn't work as I expected. Here is the screenshot:
My html:
Ionic Blank Starter
<ion-slide-box>
<ion-slide ng-repeat="image in images">
<div class="slider-container">
<img ng-src="{{image.src}}" style="width:100%;height:auto;margin:0;display:block" >
<button class="bottom-right button button-positive icon-left ion-home">Home</button>
</div>
</ion-slide>
</ion-slide-box>
The css:
.slider-container {
margin: 0;
padding:0;
position:relative;
}
.bottom-right {
position:absolute;
bottom: 0;
right: 0;
}
Can anybody help? Thanks.

And why not to do it this way?
<ion-slide-box>
<ion-slide ng-repeat="image in images">
<div class="slider-container">
<img ng-src="{{image.src}}" style="width:100%;height:auto;margin:0;display:block" >
</div>
</ion-slide>
</ion-slide-box>
<div class="slider-container">
<button class="bottom-right button button-positive icon-left ion-home">Home</button>
</div>
...moving the button (and the container <div>) out of the slider.

When I needed to put the left and right buttons ("<" and ">") I used class "row" and "col"
<div class="row">
<div class="col col-10">
<button class="button button-block button-icon button-clear ion-chevron-left" ng-click="slidePrevious()"></button>
</div>
<div class="col">
<ion-slide-box on-slide-changed="mudaSlide($index)">
<ion-slide ng-repeat="i in items">
<img class="button " ng-src="{{i.imagem}}" style="width: 128px; height: 128px; padding: 0; border: none; background: none;" ng-click="abreExibecaoImagem($index)"></img>
</ion-slide>
</ion-slide-box>
</div>
<div class="col col-10">
<button class="button button-block button-icon button-clear ion-chevron-right" ng-click="slideNext()"></button>
</div>
</div>
Result

Related

Displaying close (X) button in corner of image in css grid

I have images of different sizes and x/y ratios in a responsive CSS grid.
I need a ✖️ button in the top-right corner of each image.
So in each grid cell I put a form, and inside the form - a button and an image:
<form action="/destroyImage" method="POST">
<button type="submit" class="close">
<span>×</span>
</button>
<img src="/pub/myimage123.jpg"/>
</form>
The questions:
How can I place the center of the button on the corner of the image?
How can I get a better looking ✖️ button (I use Bootstrap 4)?
To get the 'X' in the top right hand corner you could do:
.AClass{
right:0px;
position: absolute;
}
<form action="/destroyImage" method="POST">
<div style="position:relative;">
<button type="submit" class="close AClass">
<span>×</span>
</button>
<img src="/pub/myimage123.jpg"/>
</div>
</form>
To get a better cross I would suggest using Font Awesome or some variant of that.
You can adjust right by your perspective
button{
position: absolute;
z-index: 1;
right: 0;
}
img {
position: relative;
width: 100%;
}
<form action="/destroyImage" method="POST">
<div class="1st">
<button type="submit" class="close">
<span>×</span>
</button>
<img src="https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg">
</div>
<div class="2nd">
<button type="submit" class="close">
<span>×</span>
</button>
<img src="https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg">
</div>
<div class="3rd">
<button type="submit" class="close">
<span>×</span>
</button>
<img src="https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg">
</div>
</form>
FOR GRID
you can use position-absolute and position-relative BS4 class for image and button
button{
position: absolute;
z-index: 1;
right: 20px;
}
img {
position: relative;
}
button span {
color: red; // for testing purpose
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<form action="/destroyImage" method="POST">
<div class="row">
<div class="col-4">
<div class="1st">
<button type="submit" class="close">
<span>×</span>
</button>
<img class="w-100" src="https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg">
</div>
</div>
<div class="col-4">
<div class="2nd">
<button type="submit" class="close">
<span>×</span>
</button>
<img class="w-100" src="https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg">
</div>
</div>
<div class="col-4">
<div class="3rd">
<button type="submit" class="close">
<span>×</span>
</button>
<img class="w-100" src="https://www.gettyimages.ie/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg">
</div>
</div>
</div>
</form>

Adjust size of two dynamic elements to match height

I'm trying to increase the size of the ion-slide and the img to match each other.
I'm trying to do this using CSS, but I'm not managing to increase the size of the two together.
HTML:
<ion-view view-title="Prefeitura Municipal">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
<ion-content>
<ion-slide-box>
<ion-slide>
<div class = "box boxImagem">
<img ng-src="img/Boletos.jpg" class="minha-imagem">
</div>
</ion-slide>
<ion-slide>
<div class = "box boxImagem2">
<img ng-src="img/Arraiá.jpg" class="minha-imagem">
</div>
</ion-slide>
<ion-slide>
<div class = "box boxImagem3">
<img ng-src="img/Alimentação.jpg" class="minha-imagem">
</div>
</ion-slide>
</ion-slide-box>
<div>
<div class="row icon-row">
<ion-item class="col text-center">
<img class="full-image" src="img/capitol-building.png"></img>
<br>Prefeitura
</ion-item>
<ion-item class="col text-center">
<img class="full-image" src="img/leader-with-loudspeaker.png" ui-sref="app.principal"></img>
<br>Ouvidoria<br>
</ion-item>
<ion-item class="col text-center">
<img class="full-image" src="img/earth-pictures.png"></img>
<br>Turismo<br>
</ion-item>
</div>
<div class="row icon-row">
<ion-item class="col text-center">
<img class="full-image" src="img/college-graduation.png"></img>
<br>Educação <br>
</ion-item>
<ion-item class="col text-center">
<img class="full-image" src="img/doctor-stethoscope.png"></img>
<br>Saúde
</ion-item>
<ion-item class="col text-center">
<img class="full-image" src="img/bus-service.png"></img>
<br>Serviços<br>Públicos
</ion-item>
<!-- <ion-item class="col text-center">
<a class="botao button button-positive" href="#/app/site">Icon</a>
<br>Site
</ion-item> -->
</div>
</div>
</ion-content>
<div class="bar bar-footer bar-balanced">
<button class="button icon ion-android-home">Inicio</button>
<h1 class="title">Prefeitura</h1>
<button class="button icon ion-earth pull-right">Site</button>
</div>
</ion-view>
CSS
boxImgem, .boxImagem2, .boxImagem3{
width: 100%;
height: 100%;
}
.minha-imagem{
float: left;
width: 100%;
text-align: center;
margin: 0px 0px 0;
}
As far as I know the width is set via JavaScript and thus will overwrite the css rules.
Also it's easier to help if you use a service such as codepen to create a working demo of your code

How to set div in vertically center in Html or Css

<ion-view class="ion" view-title="Browse">
<ion-content class="content" >
<div class="list landing-div">
<img class="landing-image" src="img/slpash_logo.png" >
<div class="row sub-div">
<div class="col">
<button class="button icon-left ion-person button-full landing-button-left" type="submit">LOGIN</button>
</div>
<div class="col">
<button class="button icon-right ion-android-list button-full landing-button-right" ui-sref="#/app/register" type="submit">SIGNUP</button>
</div>
</div>
</div>
</ion-content>
</ion-view>
In the div two button and on image now how to set div in vertically center.
<ion-view class="ion" view-title="Browse">
<ion-content class="content" >
<div class="list landing-div">
<img class="landing-image" src="img/slpash_logo.png" >
div{
vertical-align: text-top;
}
<div class="row sub-div">
<div class="col">
<button class="button icon-left ion-person button-full landing-button-left" type="submit">LOGIN</button>
</div>
<div class="col">
<button class="button icon-right ion-android-list button-full landing-button-right" ui-sref="#/app/register" type="submit">SIGNUP</button>
</div>
</div>
</div>
</ion-content>
</ion-view>

how to change the background image in ionic?

I want to set a image for background in ionic. here is my code.it's not working.in here style sheet is not working. when I should add the style sheet ? I dnot know how to find the error.
<ion-side-menus enable-menu-with-back-views="false" style="background: url('../img/background.jpg');background-size: 100% 100%;background-repeat: no-repeat;color: #EF4836;">
<ion-side-menu-content>
<ion-nav-bar class="bar bar-header ionBarM " align-title="center">
<ion-nav-back-button style="color: white">
</ion-nav-back-button>
<ion-nav-buttons side="right">
<button class="button button-icon button-clear button-light ion-navicon custom-icon" menu-toggle="right" style=" color: white;">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<div class="bar bar-subheader ionSubBar ">
<div class="button-bar">
</div>
</div>
<ion-content class="has-subheader" style="background: url('../img/background.jpg');background-size: 100% 100%;background-repeat: no-repeat;color: #EF4836;">
<ion-refresher .... </ion-refresher>
<ion-list>
<div class="list list-inset" data-ng-repeat="announcement in announcements">
<a class="item item-thumbnail-left" ui-sref="app.shop({id:announcement.id})" ng-click="showshop({{$index}})">
......
</a>
</div>
</ion-list>
</ion-content>
</ion-side-menus>
Do like this,
Style.css
/*Back Ground image For App*/
ion-view {
background-image:url("../img/background.jpg") !important;
background-repeat:no-repeat;
background-size:cover;
overflow:hidden;
}

Ionic header hide content despite class "has-header"

On an app with Ionic and AngularJs, I try to create a new template with a header. Unfortunately some content is hidden by the header.
Here is my code:
<link href="http://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet"/>
<div class="bar bar-header bar-stable">
<h1 class="title">XXX</h1>
</div>
<ion-content class="has-header">
<div class="padding-horizontal">
<h4 class="center">Sign in</h4>
<button class="button button-block button-positive">Sign In</button>
</div>
<hr>
<div class="padding-horizontal">
<h4 class="center">Don't have an account?</h4>
<button class="button button-block button-positive">Sign Up</button>
</div>
</ion-content>
Or JsFiddle: http://jsfiddle.net/cyef9sxs/1/
Thank you!
Well you need to specify the position absolute and width for the ionic element.
.has-header {
top: 44px;
position:absolute;
width: 100%;
}