Ionic 4 tabs: How to create custom tabs - ionic4

I am trying to style my tabs to look like what's shown in the link.
.
I currently have the default tab style and I don't know how to go about adjusting it to look like what is shown in the linked image. Any help from the community will be appreciated.

Here is my crack at it,
TESTED ON CHROME Pixel 2 XL emulator this is important because the variables I used will absolutely look different on different screen ratios. I personally used 411x823 which is the screen dimension on a Pixel 2 XL phone. You will need to handle all of the necessary screen dimension cases on your own through css media queries to get a general solution.
Initial Screen: this is what I started with. I started with what looks like the default tabs ionic application. Like what you have. Since we're dealing with only html and scss that is what I will show.
tabs-page.scss starting file.
.tabbar {
justify-content: center;
}
.tab-button {
max-width: 200px;
}
::ng-deep ion-icon.icon-button {
background: var(--ion-color-primary-tint)!important;
color: white;
border-radius: 50%!important;
}
tabs-page.html starting file.
<ion-tabs>
<ion-tab-bar *ngIf="tabSlot === 'bottom'" slot="bottom">
<ion-tab-button tab="marketplace">
<ion-icon mode="md" name="home"></ion-icon>
<ion-label>Marketplace</ion-label>
</ion-tab-button>
<ion-tab-button tab="friends">
<ion-icon name="contacts"></ion-icon>
<ion-label>Friends</ion-label>
<ion-badge *ngIf="friendCount > 0" color="danger">{{friendCount}}</ion-badge>
</ion-tab-button>
<ion-tab-button (click)="openRequestPage()">
<ion-icon name="add-circle-outline" class="icon-button"></ion-icon>
<ion-label>Request</ion-label>
</ion-tab-button>
<ion-tab-button tab="notifications">
<ion-icon name="notifications"></ion-icon>
<ion-label>Notifications</ion-label>
<ion-badge *ngIf="notificationCount > 0" color="danger">{{notificationCount}}</ion-badge>
</ion-tab-button>
<ion-tab-button tab="settings">
<ion-icon name="settings"></ion-icon>
<ion-label>Settings</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
End Screen: This is what you're looking for in a rough sense.
End result: this is what I ended up creating from the code I had started with. The solution involves using the box-shadow css attribute to give the "negative" border-radius styling. And then what you need to do is position your center button slightly above your tab-bar. I used this tutorial to guide me. Also looking up how box-shadow works helps with getting the specifics sorted out.
tabs-page.scss ending file.
.tabbar {
justify-content: center;
}
.tab-button {
max-width: 200px;
}
::ng-deep ion-icon.icon-button {
background: var(--ion-color-primary-tint)!important;
color: white;
border-radius: 50%!important;
}
:host ::ng-deep .tabs-inner {
position: unset!important;
contain: size style!important;
}
.bottom-tab-bar {
--background: transparent;
--border: 0;
}
ion-tab-button {
--background: beige;
}
.button-center {
--background: transparent!important;
ion-icon {
height: 50px;
width: 50px;
font-size: 75px;
}
}
ion-tab-bar {
&:before {
box-shadow: 0 387px 0 300px beige;
position: absolute;
margin-top: -48px;
padding: 56px;
border-radius: 65%;
content: '';
}
}
.inner-left-btn {
border-radius: 0 39% 0 0; // create the curved style on the left side of the center
}
.inner-right-btn {
border-radius: 39% 0 0 0; // create the curved style on the right side of the center
}
.inner-center-btn {
position: absolute;
left: calc(50% - 35px); // position your button in the center
bottom: 20px; // position your button slightly above the half bezel
font-size: 70px;
--background: transparent;
}
tabs-page.html ending file.
<ion-tabs>
<ion-icon name="add-circle-outline" class="icon-button inner-center-btn" (click)="openRequestPage()"></ion-icon>
<ion-tab-bar *ngIf="tabSlot === 'bottom'" slot="bottom" class="bottom-tab-bar">
<ion-tab-button tab="marketplace">
<ion-icon mode="md" name="home"></ion-icon>
<ion-label>Marketplace</ion-label>
</ion-tab-button>
<ion-tab-button tab="friends" class="inner-left-btn">
<ion-icon name="contacts"></ion-icon>
<ion-label>Friends</ion-label>
<ion-badge *ngIf="friendCount > 0" color="danger">{{friendCount}}</ion-badge>
</ion-tab-button>
<ion-tab-button class="button-center">
<div></div>
</ion-tab-button>
<ion-tab-button tab="notifications" class="inner-right-btn">
<ion-icon name="notifications"></ion-icon>
<ion-label>Notifications</ion-label>
<ion-badge *ngIf="notificationCount > 0" color="danger">{{notificationCount}}</ion-badge>
</ion-tab-button>
<ion-tab-button tab="settings">
<ion-icon name="settings"></ion-icon>
<ion-label>Settings</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>

Related

Can I use Bulma dropdown in Bulma tabs?

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>

Fixed navBar and sidebar overlap Semantic UI

I'm looking to maintain fixed navbar irregardless of sidebar with it appearing under the navbar as in here with attached top/bottom:
http://codepen.io/redshift7/pen/VaKmjq
<div class="ui bottom attached segment">
<div class="ui inverted labeled icon left inline vertical demo sidebar menu">
Attached segment won't work with fixed navbar where it will stretch through the page. I'd rather see the answer in vue.js.
You need to make following CSS changes for this to work:
.menu {
position: fixed;
top: 0px;
z-index: 10001;
width: 100%;
}
.pusher {
margin-top: 36px;
}
.pushable {
margin-top: 0px !important;
}
Working codepen: here

CSS Animations Work in IE10 and Firefox, NOT in Webkit Browsers

this is my first time posting. I've searched and trouble shooted for the past two hours, but haven't been able to solve my problem. I suspect it's something stupid and simple, but I just can't find the error.
This is an excerpt from my testing page http://www.enviroprofit.com/sandbox.php. The rss feed blocks in the lower-right of the screen are supposed to scroll through the headline within the block. This action works properly in IE10 and Firefox.
I've added the -webkit- properties to the CSS, but they don't seem to work.
<style type="text/css">
#keyframes tickup {
from {transform: translateY(0px); }
to {transform: translateY(-1000px); }
}
#-webkit-keyframes tickup {
from { -webkit-transform: -webkit-translateY(0px); }
to { -webkit-transform: -webkit-translateY(1000px); }
}
div.ticker {
animation-name: tickup; -webkit-animation-name: tickup;
animation-duration: 120s; -webkit-animation-duration: 120s;
animation-direction: normal; -webkit-animation-direction: normal;
animation-iteration-count: 50; -webkit-animation-iteration-count: 50;
}
</style>
<div class="blog_block" style="width: 160px; height: 18px; overflow: hidden; ">
<a href="'.$feed_link.'" target="_blank">
<div style="position:absolute; width:100%; height:100%; overflow: hidden; top:0; left: 0; z-index: 10; background-image: url(\'empty.gif\'); " ></div>
</a>
<img src="'.$feed_icon.'" width="15" style="float:left; " />
<div class="ticker" style="animation-delay:'.$animation_start_time.'s; position:relative; width:120px; height:100%; padding-left: 10px; float:left; text-align: center; font-size: 12px; " >
Don't worry if the tags don't match up. The HTML is just an excerpt from php script. Thanks much.
animations are supported in -webkit browsers:
http://caniuse.com/#feat=css-animation
also you missing the properties animation-duration, animation-delay and animation-fill-mode for -webkit browsers
or you could try using the shorthand animation property
animation: <single-animation-name> || <time> || <single-animation-timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state>;
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_animations
http://www.w3.org/TR/css3-animations/

fontawesome links not working in my sticky footer in Safari

My sticky footer with my fontawesome icons is displaying perfectly in all browsers, but in Safari, the links aren't working.
Here is my code:
<style>
h4 {
font-size: 1em;
color: #A0A0A0;
bottom: 15px;
position: relative;
letter-spacing: 10px;
}
.footer{
position: fixed;
left:0px;
width: 100%;
bottom: 0px;
height: 20px;
background: #404040;
padding-bottom: 25px;
opacity:0.95;
}
</style>
......
<div class="footer">
<h4>
<a href="https://twitter.com/">
<i class="icon-twitter icon-2x"></i> </a>
<a href="https://www.facebook.com/">
<i class="icon-facebook icon-2x"></i></a>
<a href="http://wordpress.com/">
<i class="icon-rss icon-2x"></i></a>
</h4>
</div>
Can anyone tell me why this doesn't work in safari? And how to fix it?
I just into this problem. I believe this is caused by safari giving the target no dimensions (i.e. 0px x 0px). If you force inline-block on the <i> element it should to work correctly.
Had the same problem.
I added to the icon's class
display:inline-block;
and it worked fine!

JQuery-Mobile content area 100% height between head and foot

A lot of topics on this... but not getting the point how to do it.
I have my JQM Header and Footer. I want the content area to fill the 100% height in between head and foot.
Thats my code, how is it possible?
<body>
<div data-role="page" id="entryPage" data-theme="d">
<div data-role="header" id="header" data-position="fixed" data-theme="d">
<h1>Page Title</h1>
</div><!-- /header -->
<div data-role="content" id="content" data-theme="d">
<div id="columnwrapper">
<div id="leftcolumn">
<div class="innertube">
Point 1
</div>
<div class="innertube">
Point 1
</div>
</div>
</div>
<div id="rightcolumn">
<div class="innertube">
<div id="switch1">
test
</div>
</div>
<div class="innertube">
test2
</div>
</div>
<div id="contentcolumn">
<div class="innertube">Content</div>
<div class="innertube">Content</div>
</div>
</div><!-- /content -->
<div data-role="footer" id="footer" data-position="fixed" data-theme="d">
<div id="switch2">
Expand main menu
</div>
</div><!-- /footer -->
</div><!-- /page -->
</body>
CSS:
#columnwrapper{
float: left;
width: 100%;
margin-left: -75%; /*Set left margin to -(contentcolumnWidth)*/
background-color: #C8FC98;
}
#leftcolumn{
margin: 0 40px 0 75%; /*Set margin to 0 (rightcolumnWidth) 0 (contentcolumnWidth)*/
background: #C8FC98;
}
#rightcolumn{
float: left;
width: 40px; /*Width of right column*/
margin-left: -40px; /*Set left margin to -(RightColumnWidth)*/
background: yellowgreen;
}
#contentcolumn{
float: left;
width: 75%; /*Width of content column*/
background-color: blue;
}
.innertube{
margin: 0px; /*Margins for inner DIV inside each column (to provide padding)*/
margin-top: 0;
}
Actually the inner area only fills the height depending on the content... means 2 divs 2 rows, but not 100%..
Thanks
The CSS position: fixed doesn't work correctly in mobile browsers. My experience is with Android and iOS browsers and none of them impliment position: fixed properly (the exception is the iOS 5 browser but it's still in beta).
Rather than fixing an element to the screen and not moving it when the user scrolls in mobile browsers it tends to be treated like position: absolute and it moves when the page scrolls.
Also using the CSS overflow property won't allow scrolling on most mobile devices (iOS supports it but the user has to know to use two fingers while scrolling in a scrollable-div).
You can however use CSS but be aware you will need to use position: absolute or you can use JavaScript to set the heights on the elements.
Here is a jQuery Mobile solution using JavaScript to set the heights of the pseudo-page elements:
$(document).delegate('#page_name', 'pageshow', function () {
var the_height = ($(window).height() - $(this).find('[data-role="header"]').height() - $(this).find('[data-role="footer"]').height());
$(this).height($(window).height()).find('[data-role="content"]').height(the_height);
});
To get a flawless finish you need to take into consideration the behavior of the target device's address bar because if you want a fullscreen webpage then you have to add the height of the address bar to the height of the page.
Thanks, Jasper! That helped me a lot.
I had to mess around a lot to get this to work with multiple headers/footers, and to account for the url bar in ios. I thought I would share my solution for any one else having this issue.
This is working for me so far in ios simulator, but I would be eager to hear how it works on other devices.
/* detect device */
var ua = navigator.userAgent,
iphone = ~ua.indexOf('iPhone') || ~ua.indexOf('iPod'),
ipad = ~ua.indexOf('iPad'),
ios = iphone || ipad,
android = ~ua.indexOf('Android');
$(document).delegate('#the_page', 'pageshow', function () {
var $page = $(this),
$target = $(this).find('.fullHeight'),
t_padding = parseInt($target.css('padding-top'))
+ parseInt($target.css('padding-bottom')),
w_height = (ios)? screen.height-65: $(window).height(); // "-65" is to compensate for url bar. Any better ideas?
headFootHeight = 0;
// Get total height for all headers and footers on page
$page.find('[data-role="footer"], [data-role="header"]').each(function() {
var myTotalHeight = $(this).height()
+ parseInt( $(this).css('padding-top') )
+ parseInt( $(this).css('padding-bottom') );
headFootHeight += myTotalHeight;
});
var the_height = (w_height - headFootHeight);
$page
.height(w_height)
.find('.fullHeight')
.height(the_height - t_padding);
});
This script is setting a 100% height on '.fullHeight', instead of [data-role=content] to give more flexibility, but you can just add the fullHeight class to your [data-role=content] element.
One issue I'm still having is compensating for the url bar in ios, and finding a window height that works across devices. Any ideas on that?
the CSS:
footer {
display: block;
position: fixed;
left: 0;
bottom: 0;
right: 0;
height: 50px;
background-color: #333;
overflow: hidden;
z-index:1000;
-webkit-transform: translateZ(0);
opacity:.9;
}
header{
display:block;
position: fixed;
left:0;
right:0;
top:0;
height:50px;
overflow: hidden;
}
section{
display:block;
position:fixed;
left:0;
top:50px;
bottom:50px;
right:0;
overflow-y: auto;
}
nav{
display:block;
height:100%;
-webkit-backface-visibility: hidden;
}
.body{
overflow-y: hidden;
}
.bar {
border: 1px solid #2A2A2A;
background: #111111;
color: #ffffff;
font-weight: bold;
text-shadow: 0 -1px 1px #000000;
background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#111)); /* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, #3c3c3c, #111); /* Chrome 10+, Saf5.1+ */
background-image: -moz-linear-gradient(top, #3c3c3c, #111); /* FF3.6 */
background-image: -ms-linear-gradient(top, #3c3c3c, #111); /* IE10 */
background-image: -o-linear-gradient(top, #3c3c3c, #111); /* Opera 11.10+ */
background-image: linear-gradient(top, #3c3c3c, #111);
}
the only html needed:
<header class="bar" id="AllHead"></header>
<div data-role="content" class="content" id="home"><section><nav></nav></section></div><!-- /content -->
<footer class="bar" id="allFoot"></footer>
</div><!-- /page -->
you can then set whatever items you want inside the footer and the bottom nav bar
this will always look right, no matter what happens, also this wont flash on and off everytime you touch something. hope it helps