I am using bootstrap 3 to create my nav bar. I also needed to place a search bar on the navbar. So my code looks like this
<div class="navbar navbar-default">
<a class="navbar-brand">Logo Image</a>
<ul class="nav navbar-nav">
<li class="active">Calendar</li>
<li>Customerr</li>
<li>Providers</li>
</ul>
<form class="navbar-form navbar-right" action="">
<div class="form-group">
<input type="text" class="form-control mac-style" name="Search" id='nav-search' placeholder="Search">
</div>
<input type="submit" name="search" value="Search" class="btn btn-default" >
</form>
</div>
I want the input box to get bigger when the usere focuses to search but to the left like stack's search bar. I tried the following css at first
.mac-style:focus{
width: 500px;
}
and the input box grows to the left but the transition is very rough. So i tried to add the transition property(webkit moz o an default) like this
.mac-style:focus{
width: 500px;
-webkit-transition: width 1s ease-in-out;
-moz-transition:width 1s ease-in-out;
-o-transition: width 1s ease-in-out;
transition: width 1s ease-in-out;
}
but the input changes width to the right going behind the search button and off the nav-bar. Ho can i make it act like the css without the transition(grow to the left). The way my nav bar is created, is there a way to make it stop when it reaches the last li so it is more dynamic?
If i correctly understand you - take a this fiddle . I don't know yours other css styles, but you can a create your fiddle and show it to us.
The reason is, you should give width to normal state also.
JSFIDDLE : http://jsfiddle.net/surjithctly/mdXqr/
.mac-style {
width: 100px;
-webkit-transition: width 1s ease-in-out;
-moz-transition:width 1s ease-in-out;
-o-transition: width 1s ease-in-out;
transition: width 1s ease-in-out;
}
.mac-style:focus{
width: 260px;
}
Related
does anybody know why the transition is working when I first click the button, then the text disappears after 2s. But it should also show up after 2sek when i click the button again after the text has been hidden. But when I click it, the text appears immediately.
HTML:
<div class="container">
<button class="button">Hit me</button>
<div class="wrapper">
<div class="title-bar">This is the title</div>
</div>
</div>
CSS:
.container .title-bar {
visibility: visible;
-webkit-transition: visibility 2s;
transition: visibility 2s;
}
.container.fixed .title-bar {
visibility: hidden;
-webkit-transition: visibility 2s;
transition: visibility 2s;
}
JS:
$('.button').click(function() {
if ($('.container').hasClass('fixed')) {
$('.container').removeClass('fixed');
} else {
$('.container').addClass('fixed');
}
});
I created a pen for this:
https://codepen.io/anon/pen/QqeNrW
Thanks!
From the docs:
visibility: if one of the values is visible, interpolated as a discrete step where values of the timing function between 0 and 1 map to visible and other values of the timing function (which occur only at the start/end of the transition or as a result of cubic-bezier() functions with Y values outside of [0, 1]) map to the closer endpoint; if neither value is visible then not interpolable.
So, the visibility is going , so to say, from 0 to 1, and in the intermediate steps will be some value between 0 and 1.
But, all the fractionary values are mapped to visible, and this produces the effect that you see.
Instead of the setting a transition-duration, set a transition-delay and it will work as expected
$('.button').click(function() {
if ($('.container').hasClass('fixed')) {
$('.container').removeClass('fixed');
} else {
$('.container').addClass('fixed');
}
});
.container .title-bar {
visibility: visible;
-webkit-transition: visibility 2s;
transition: visibility 0s 2s;
}
.container.fixed .title-bar {
visibility: hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<button class="button">Hit me</button>
<div class="wrapper">
<div class="title-bar">This is the title</div>
</div>
</div>
I've got a problem with one animation in angular. I want to make newly created element to 'travel' from input where it was created to destination.
I think it is connected with changing css position attribute while animation from absolute to relative, but don't know why it doesn't work.
Here is my code:
part of index.html:
<form ng-submit="add(name)">
<input type="text" id="input-element" class="form-control" ng-model="name" />
<button type="button" class="btn btn-default">Add</button>
</form>
<ul>
<li class="animation" ng-repeat="item in list"><b>{{item}}</b></li>
</ul>
css:
.animation.ng-enter {
-webkit-transition: 0.5s linear all;
-moz-transition: 0.5s linear all;
-o-transition: 0.5s linear all;
transition: 0.5s linear all;
}
.animation.ng-enter {
left: 25px;
top: 25px;
opacity: 0;
position: absolute;
}
.animation.ng-enter.ng-enter-active {
position: relative;
left: 0;
top: 0;
opacity: 1;
}
controller's body (not connected with my problem):
$scope.list = [];
$scope.add = function(name) {
$scope.list.push(name);
};
When I remove position: relative from .animation.ng-enter.ng-enter-active, it is always as absolute. When I leave it, position is always relative.
How to make such 'travel' animation from input to destination with angular-animate?
Here is my plunker: http://plnkr.co/edit/m1xoP6GpJJZzhFhjALRd?p=preview.
I'm just not sure why these transitions are so laggy.I've never had this happen to me before.
My code is:
<section class='containgrid'>
<div class="grid">
<div class="unit one-third">
<div class="eventbox">
<img class='imgfit' src='images/choice1.jpg'/>
<h2 class='contactheading'>Questions?</h2>
<h3 id='subheading'>subheading</h3>
</div>
</div>
</div>
</section>
Not shown is 2 more "unit one-third"s, I took them out for clarity but the other two are the exact same as the first one. As you can tell I'm using gridism for a simple grid layout, my relevant css code is so:
.imgfit{
width:98%;
margin:.2em;
height:375px;
}
.eventbox{
background-color:#F1EFEF;
margin-top:15%;
width:100%;
-webkit-transition: background-color 0.3s;
-moz-transition: background-color 0.3s;
transition: background-color 0.3s;
-webkit-transition: border 0.3s;
-moz-transition: border 0.3s;
transition: border 0.3s;
border:solid #F1EFEF .2em;
}
.eventbox:hover{
background-color:#DBDBDB;
border:solid #7D7D7D .2em;
}
This seems really straightforward to me, but when I open it up in browser it becomes really laggy and is not smooth at all.Why?
what I would like is to make my site menu switching between panel and classic horizontal menu.My goal is to change the site menu depending on the screen size (desktop/mobile)... but it is another story!
I have the following working solution (http://jsfiddle.net/998HD/2/):
HTML
<div data-role="page">
<div data-role="header">
<h1>Title</h1>
Panel
</div>
<div id="pnl" data-role="panel" data-display="overlay">
<ul data-role="listview">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</div>
<div data-role="content">Lorem ipsum</div>
</div>
CSS
.menu.ui-panel {
position: relative;
width: 100%;
min-height: 0
}
.menu.ui-panel .ui-li {
display: inline-block;
margin: 0;
border: 0
}
JS
$('#lnkpnl').click(function() {
var menu = 1; // 0 = panel, 1 = horizontal
if (menu) $('#pnl').addClass('menu').insertAfter('.ui-header');
$('#pnl').panel('open')
})
JQuery Mobile moves #pnl panel after the header and content and this prevents me from simply apply:
.menu.ui-panel {
position: static
/*... other props ...*/
}
and avoid line 1 and 2 in javascript code.
So, I ask you. Is my solution the best? Is there a pure css solution?
Many thanks.
You are right on point. There is a way to do this with transition CSS. I included a Fiddle to show you, but it is jquery assisted. Then again, this is a very light JS call so it shouldn't toruble your application. Then again, neither is yours. So you are good either way.
-webkit-transition:all 1.0s ease-in-out;
-moz-transition:all 1.0s ease-in-out;
-o-transition:all 1.0s ease-in-out;
transition:all 1.0s ease-in-out;
Hope it helps
FIDDLE
this is probably easier to see at the fiddle. I have social icons with their link displaying next to them. The problem is, the social icons are 40x40. The text displays at the foot of the icon. I want the text in the center of the icons. How do i pull that off? Can't seem to figure it out. Any help is greatly appreciated!
http://jsfiddle.net/grem28/meY8K/1/
<footer>
<ul>
<li><div class="footer_icon facebook"></div><div class="iconText">Facebook.com</div></li>
<li><a class="inst" href="http://instagram.com" target="_blank" title="Follow on Instagram"><div class="footer_icon instagram"></div><div class="iconText">We're on Instagram</div></a></li>
<li><a class="twt" href="https://twitter.com" target="_blank" title="Follow us # Twitter.com"><div class="footer_icon twitter"></div><div class="iconText">Twitter.com</div></a></li>
<li class="right"><a class="pin" href="http://www.pinterest.com" target="_blank" title="Visit Pinterest.com"><div class="footer_icon pinterest"></div><div class="iconText">Pinterest.com</div></a></li>
</ul>
</footer>
The following seems to work:
.footer_icon {
height: 40px;
width: 40px;
-webkit-transition: all ease 0.3s;
-moz-transition: all ease 0.3s;
-o-transition: all ease 0.3s;
-ms-transition: all ease 0.3s;
transition: all ease 0.3s;
display:inline-block;
vertical-align: middle;
}
add vertical-align: middle to your CSS rule for .footer-icon.
See demo at: http://jsfiddle.net/audetwebdesign/g3Jk6/