I use Ionic 3, below the code cannot align the title to center, it moves a little bit right due to the ion-buttons. How can it be solved?
<ion-header>
<ion-toolbar color="primary">
<ion-buttons slot="start">
<ion-button (click)="close()">
<ion-icon name="arrow-back"></ion-icon>
</ion-button>
</ion-buttons>
<ion-title text-center>{{bookName}}</ion-title>
</ion-toolbar>
</ion-header>
just add mode=ios at title like this
<ion-title mode=ios>Your Title</ion-title>
Tested in ionic 3, 4 and 5 both
You could try to wrap your title in a div like this:
<div text-center>
<ion-title>YOUR TITLE</ion-title>
</div>
This is not ionic v3, the components that you are using are ionic v4, anyway, you can try it this way:
<ion-header>
<ion-toolbar color="primary" text-center>
<ion-buttons slot="start">
<ion-button (click)="close()"><ion-icon name="arrow-back"></ion-icon></ion-button>
</ion-buttons>
<ion-title>{{bookName}}</ion-title>
</ion-toolbar>
</ion-header>
An easy way is to do it with css you can put this class
page-name {
ion-title {
position: “relative”;
left: 5px —- here what you desire
}
}
Use class ion-text-center like below:
<IonTitle class="ion-text-center">Game</IonTitle>
For Ionic 4:
In your ion-title component,
Add class="ion-text-center" to center-align it. This will also produce the problematic offset to the right, due to button.
Add style="margin-left: -52px;" (calculate the problematic offset you want to equalize, in my case it was 52px).
.
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
</ion-buttons>
<ion-title class="ion-text-center" style="margin-left: -52px;">
My App
</ion-title>
</ion-toolbar>
Set text align center and indent it by -45px to adjust back button space
.header .toolbar-title{
text-align: center;
text-indent: -45px;
}
Try this align="center"
<ion-header>
<ion-toolbar>
<ion-title align="center">Register</ion-title>
</ion-toolbar>
</ion-header>
Instead of tweaking styles and element attributes, you can simply set the ionic config to set the title centered across all platforms.
IonicModule.forRoot(MyApp, {
backButtonText: 'Back',
backButtonIcon: 'ios-arrow-back',
mode: 'ios', // THIS CONFIG CENTERS THE TITLE ACROSS ALL PLATFORMS
iconMode: 'md',
modalEnter: 'modal-slide-in',
modalLeave: 'modal-slide-out',
tabsPlacement: 'bottom',
pageTransition: 'ios-transition',
swipeBackEnabled: true
}),
The below solution worked for me. Even if there is a button on one side, it will still work.
ion-title {
text-align: center;
padding: 0 78px 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
Accepted answer doesn't align title on center position in perfect manner. I have added custom CSS to achieve this.
Ex.
<ion-header>
<ion-toolbar color="primary">
<ion-title class="header-title">Payment Detail</ion-title>
<ion-buttons slot="secondary">
<ion-button>
<ion-icon name="log-out" class="logout-icon" (click)="logout()"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
.header-title {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 0 150px;
text-align: center;
}
for ionic 5x this seems to work
<div style="margin-left: auto;margin-right: auto;" classs="ion-text-center">
<ion-title>Testimonials</ion-title>
</div>
Related
I want to blur the whole background except the progress bar in vuetify I searched a lot for the solution but did not find any of it.
Question: make the whole background dull except for the progress bar
here is how my html layout is
<div class="resume-wrapper">
<v-container fluid>
...
</v-container>
<div class="prg-wrapper">
<span style="display: inline-block; margin-bottom: 17px;">Downloading...</span>
<v-progress-linear
color="deep-purple accent-4"
indeterminate
rounded
height="6"
></v-progress-linear>
</div>
</div>
My css is something like this
.prg-wrapper{
position: fixed;
left: 50%;
top: 29%;
transform: translate(-50%, -50%);
}
I'm using vuetify-2.6.x here is documentation for progress-bar https://vuetifyjs.com/en/components/progress-linear/#file-loader
Please help me thanks in advance!!
You should probably use something like this
<v-overlay :value="spinnerVisible" z-index="998">
<v-progress-circular indeterminate size="64" />
</v-overlay>
Otherwise, you can blur the background with a backdrop filter:
<div class="overlay">
<v-progress-linear
color="deep-purple accent-4"
indeterminate
rounded
height="6"
/>
</div>
<style>
.overlay
{
background-color: rgba(145, 150, 158, 0.6);
backdrop-filter: blur(2px);
}
</style>
I'm using ImageKit to store images for my portfolio (more specifically, I'm using their Vue SDK. Typically my images are horizontal/landscape, however I just added a few that are vertical orientation. What I'd like to do is force crop the vertical images so that they are the same dimensions as the horizontal images. Does anybody have any experience with this?
<template>
<client-only>
<v-col
cols="12"
sm="6"
md="6"
lg="4"
xl="3">
<v-card
class="image-card"
flat
nuxt
:ripple="false"
:to="imageLink">
<div class="overlay">
<h3
class="display-2 text--white gallery-name">
{{ item.title }}
</h3>
<div class="btn-wrapper">
<v-btn
depressed
:ripple="false"
color="primary"
class="visit-btn"
:to="imageLink">
{{ btnText }}
</v-btn>
</div>
</div>
<i-k-image
:public-key="publicKey"
:url-endpoint="urlEndpoint"
:src="imageSrc"
:transformation="[
{ progressive: true },
{ cropMode: 'maintain_ratio' },
{ width: '500' },
]"
#contextmenu.prevent />
</v-card>
</v-col>
</client-only>
</template>
<style lang="scss" scoped>
.image-card {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
cursor: pointer;
height: 100%;
margin: 0 auto;
position: relative;
.overlay {
align-items: center;
background-color: rgba(255, 255, 255, 0.3);
bottom: 0;
display: flex;
flex-direction: column;
justify-content: center;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transition: 0.2s all ease-in-out;
visibility: hidden;
}
img.ik-image {
width: 100%;
}
}
</style>
Current result:
*I'd like the top row to be force cropped to the same dimensions as the bottom row.
You can use the <ik-image> component of Imagekit Vue SDK to set the same height and width for all of your images like this -
<ik-image :src="your_image_src" :transformation="[{ height: 300, width: 400 }]" /> (assuming you have installed Imagekit plugin using Vue.use and specified required parameters there)
I have an ion-list in the header of my side-menu but i am unable to reduce the spacing of the items. You can see in the pic where i am trying to reduce:
the list code is:
<ion-list class="sidemenu-header-list" inset=true lines="none">
<ion-item color="secondary">
<h2>{{name}}</h2>
</ion-item>
<ion-item color="secondary" class="ion-no-padding" *ngIf="school">
<ion-label style="font-size: 14px" text-wrap innerHTML={{school}}></ion-label>
<ion-icon size="small" name="school" slot="start"></ion-icon>
</ion-item>
<ion-item color="secondary" class="ion-no-padding"*ngIf="year">
<ion-label style="font-size: 14px" >{{year | translate}}</ion-label>
<ion-icon size="small" name="calendar" slot="start"></ion-icon>
</ion-item>
</ion-list>
I can see a size set on input-wrapper of 48px; which is what is forcing the height of my items; but can't see where i can modify this.
try putting the following lines in your component scss file to modify the min-height CSS variable of ion-item components
ion-item {
--min-height: 16px;
}
h2 {
padding: 0px;
margin : 0px;
}
in CSS
ion-item {
--min-height: 16px;
}
h2 {
padding: 0px;
margin : 0px;
}
in Html
<ion-item class="ion-no-padding"> // Ionic 4 or 5
I'm using Nuxt.js and Bulma. I'm making navigation using Bulma tabs(https://bulma.io/documentation/components/tabs/).
I wanna insert Bulma dropdown(https://bulma.io/documentation/components/dropdown/#hoverable-or-toggable). But it doesn't work in middle of Tabs.
I know who wanna use Bulma dropdown needs to use javascript, so I use it. But it doesn't work.
How can i fix it?
To get a dropdown working inside Bulma's tabs, you need to adjust the overflow CSS in the tabs div. I'm not sure why I had to set overflow-x and overflow-y to get this working properly, but I did.
When the dropdown is active:
overflow-x : visible;
overflow-y : visible;
When the dropdown is not active, reset to their defaults:
overflow-y : hidden;
overflow-x : auto;
Yes you can with a little amount of fiddling
There are mainly 2 problems :-
Problem 1
As bulma tabs container is flexbox, and the list of tabs are child of this flexbox, the dropdown will not be visible as it overflows out of flexbox container.
If you add overflow-y:visible to tabs container div, scrolling will happen which is not the behaviour we need
Solution
To fix this, the contents to be shown on tab selection should also come inside the tabs container as second child, so that dropdown button/link in list of
tabs has the space to show the dropdown when clicked/hovered.
#tab-container {
flex-direction: column;
height: 500px;
width: 100%
}
#content-child {
flex-grow: 1;
width: 100%
}
#list-child {
flex-grow: 0; //should be set to 0 as it will take up vertical space (it is set to 1 in bulma)
width: 100%;
}
Problem 2
When dropdown is used within bulma tabs, the anchor tags in dropdown gets styled by those specified for anchor tags in tabs.This is one of the main issue.
The dropdown shown thus will be styled very differently.
Solution
Bulma dropdown also allows us to insert div inside.
We can make use of this to overcome problem 1.
Just add this css for divs inside dropdown so as to make it behave like links.
div.dropdown-item.is-active {
background-color: rgba(55, 122, 195, 0.95);
color: #fff;
}
div.dropdown-item {
padding-right: 3rem;
text-align: left;
white-space: nowrap;
width: 100%;
cursor: pointer;
text-decoration: none;
}
div.dropdown-item:hover {
background-color: whitesmoke;
color: #0a0a0a;
}
Complete solution can be seen below and you can change as required for your use case.
div.dropdown-item.is-active {
background-color: rgba(55, 122, 195, 0.95);
color: #fff;
}
div.dropdown-item {
padding-right: 3rem;
text-align: left;
white-space: nowrap;
width: 100%;
cursor: pointer;
text-decoration: none;
}
div.dropdown-item:hover {
background-color: whitesmoke;
color: #0a0a0a;
}
#content-child {
flex-grow: 1;
width: 100%
}
#tab-container {
flex-direction: column;
height: 500px;
width: 100%
}
#list-child {
flex-grow: 0;
width: 100%;
}
<link href="https://cdn.jsdelivr.net/npm/bulma#0.8.1/css/bulma.min.css" rel="stylesheet" />
<div class="tabs is-boxed" id="tab-container">
<ul id="list-child">
<li><a>Pictures</a></li>
<li><a>Music</a></li>
<li><a>Videos</a></li>
<li><a>Documents</a></li>
<li class="dropdown is-active">
<div class="dropdown-trigger">
<a class="has-text-right custom-padding" aria-haspopup="true" aria-controls="dropdown-menu">
Drop Down
</a>
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<div class="dropdown-item">Dropdown item</div>
<div class=" dropdown-item">Other dropdown item</div>
<div class=" dropdown-item is-active">Active dropdown item</div>
<div class=" dropdown-item">Other dropdown item</div>
<hr class="dropdown-divider" />
<div class=" dropdown-item">With a divider</div>
</div>
</div>
</li>
</ul>
<div id="content-child">
content
</div>
</div>
I have a bootstrap tooltip which I have custom styled. There seems to be an issue with it. Whenever we hover over it, it opens and then immediately closes.
HTML -
<div class="container" style="padding-top:300px">
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" data-html="true" title="" data-original-title="Tooltip Text">i</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" data-html="true" title="" data-original-title="Tooltip Text">i</span>
</div>
</div>
Here's an inline link to jsFiddle
UPDATED
I made a few changes. Try this: https://jsfiddle.net/2h7jbt9n/6/
HTML
<div class="container" style="padding-top:30px">
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" title="YoHo Ho Ho" data-placement="top" data-toggle="tooltip">i</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span>A bunch of random text</span><span class="info-circle" title="YoHo Ho Ho" data-placement="top" data-toggle="tooltip">i</span>
</div>
</div>
JS
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip({
container: '.info-circle'
});
});
The issue was with padding for the info-circle. I wrapped it in a container. It doesn't flicker now.
Hope it helps.
You are no longer using the tooltip-arrow as the visual arrow you are using the :before and :after after as the visual arrow. The problem is that you have made the arrow bigger and made your own triangles. When you make your css arrow you are using borders. You have set your top border colors to white and blue to make it seem like the arrow has a border as well. In doing this you have forgotten that your arrow still has a bottom transparent border and this transparent border is covering up the element that you are hovering over to deploy the tooltip. So set your :before and :after psuedo elements for your .tooltip-arrow to have a bottom border of none. Like so:
.tooltip.top .tooltip-arrow:after {
content: " ";
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: -17px;
top: -5px;
border-width: 12px;
border-top-color: #003f6e;
border-bottom:none;
}
.tooltip.top .tooltip-arrow:before {
content: " ";
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
left: -15px;
top: -5px;
border-width: 10px 10px 0;
border-top-color: #fff;
border-bottom:none;
z-index: 1;
}