Can't align vertically in div with inline Bootstrap buttons - css

I wrote a small Angular directive that generates a step input control for numbers. I've used Bootstrap buttons (xs) for the inc/dec controls and somehow managed to simulate a fake focus on the outer container. The problem is centring vertically the spans and the input in a stable layout that keeps together when zoomed.
This is the directive template:
<ng-form name="stepNumberForm" novalidate \>
<div class="step-number"
tabindex="{{$id}}"
ng-class="{\'fake-focus\': fakeFocus}"
ng-keyup="keyControl($event)">
<span
ng-disabled="incDisable"
class="btn-primary"
ng-click="inc()">
<i class="glyphicon glyphicon-plus ">
</i>
</span>
<input type="text"
ng-style="setWidth()"
name="value"
ng-keyup="keyControl($event)"
ng-model="value"
ng-focus="selectAll($event)"
ng-blur="validate()"
class="input-xs">
<span
ng-disabled="decDisable"
class="btn-primary"
ng-click="dec()">
<i class="glyphicon glyphicon-minus">
</i>
</span>
</div>
</ng-form>
The CSS I've used is:
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.step-number{
border:1px solid;
display:inline-block;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select:none;
user-select:none;
border-radius:4px;
}
.input-xs {
font-size: 1em;
text-align: center;
border:none;
line-height: 1em;
height:1.1em;
vertical-align: middle;
}
.step-number span{
display: inline;
height: 100%;
width: 18px;
margin-bottom: 1px;
margin-top: 1px;
text-align: center;
}
.step-number span:first-child{
margin-left: 1px;
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
}
.step-number span:last-child{
margin-right: 1px;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
}
.input-xs:focus{
outline:none;
}
.step-number:focus{
outline:none;
border-color: rgba(82, 168, 236, 0.8);
outline: 0;
outline: thin dotted \9;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);
}
.fake-focus{
border-color: rgba(82, 168, 236, 0.8);
outline: 0;
outline: thin dotted \9;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);
}
.step-date{
display: inline-block;
}
The whole project is available at github.
There is also a working demo and it's available for install through $ bower install stepper
I would greatly appreciate a helping hand from anybody finding this useful. All contributors are welcome to make this small directive look good. This means: input centred vertically, buttons centred vertically, a 1px border padding inside the element, cross-browser stable and zoom stable.

I've added these CSS rules at the span or the button element that has the + sign:
padding: 1px;
position: relative;
top: -1px;
It seems to be working just fine (I've also tried resizing the viewport - tested with Firefox).
Here is a screenshot of the outcome (remember, only applied to the plus sign)
You could add the above rules to a class .stepper-buttons and add it to the span or the button element (tested with both).
Let me know if this worked for you.

Related

React inline styling of component with props value and condition check not working

I'm trying to style an appointment view in a calendar. Every made appointment could have a specific color to it. I tried to check for that color and make the top border so that it represents that color. So far it isn't showing. Does anyone see something that isn't wright?
jsx code:
<div className={props.start >= moment() ? "appointment" : " appointment disabled"} style={props.color !== null ? {borderColorTop: props.color} :{borderColorTop: '#000'}}>
</div>
scss classes that also belong to an appointment:
.appointment{
width:105%;
height:95%;
background-color:$plain-white;
margin-top:3% !important;
margin-left:3%;
border: 4px solid $plain-white;
border-radius: 5px;
padding:5px;
-webkit-box-shadow: 1px 5px 23px -2px rgba(199, 199, 199, 1);
-moz-box-shadow: 1px 5px 23px -2px rgba(199, 199, 199, 1);
box-shadow: 1px 5px 23px -2px rgba(199, 199, 199, 1);
.service{
text-align: center;
font-weight: 700;
}
}
.enable{
cursor: pointer;
border-top-color:#9DBBF5;
}
.disabled{
pointer-events: none;
border-color: $white;
border-top-color: $black;
background-color: $white;
}
Simple typo, you're using borderColorTop instead of borderTopColor in your style prop

Couldn't change the border color for each item on main menu

I have set CSS for each button on main menu. I want to change the border color for each item.
I can change the color what ever I want. But I want to pick out some specific color for each button.
This part of CSS define the border color:
#main-nav .menu-sub-content {
display: none;
padding: 0;
position: absolute;
z-index: 205;
border-top: 12px solid ;/*#F88C00*/
border-top-color: transparent !important; /*I change to transparent*/
background: #fff;/*2d2d2d*/
color:#999;
-webkit-box-shadow: 0 3px 4px 1px rgba(0, 0, 0, 0.2);
box-shadow: 0 3px 4px 1px rgba(0, 0, 0, 0.2);
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius : 3px;
-moz-border-radius-bottomright : 3px;
-moz-border-radius-bottomleft : 3px;
border-bottom-right-radius: 3px;
border-bottom-left-radius : 3px;
}
First I tried this
border-top-color: transparent !important;
And then I put this CSS for 3rd button
.ucuncu-nav.menu-sub-content{
/*border-top:12px solid;*/
border-top-color:#669900 !important;
}
But it didn't changed. How can I change it now?
Elements of your list have id's which you can use when adding separate borders for what you display on hover. Try this code:
#menu-item-17:hover .mega-menu-block {
border-top: 3px solid red !important;
}
#menu-item-7:hover .mega-menu-block {
border-top: 3px solid green !important;
}
etc, for all your <li> menu items with different id's. !important rule is here a quick solution because the is overridden for some default styles.

In CSS (specifically Bootstrap) parlance, what is a "well"?

I keep noticing class="well" in a web app using Twitter's Bootstrap, but I can't find any documentation about it, unless I just overlooked it.
Thanks.
"well" is a CSS selector simply create prominent wrapper around element
.well {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
}
The well is used as a simple effect on an element to give it an inset effect.
<div class="well">...</div>**

Adjusting fixed width to div and creating effect on css button click

I have used div event which appear with scrollbar on the page to show content.
Though I have adjusted the width of div, When it appears on the page; it reaches to right corner of the screen.
code:
<div id="txtHint" align="justify" style="z-index: 1; color:green; left: 350px; top: 270px; position: absolute; margin-top: 0px; width:500px;height:250px;overflow:auto;">
Height gets adjusted correctly, for width whatever I take i.e. 200,300, or 800px. It spans up right end.
I checked in mozilla and chrome both. I am testing it for my ec2 amazon instance.
Similarly my css button :
<input class="uibutton confirm large" type="submit" value="Connect with facebook" onclick="AjaxResponse()" >
When I click it, all actions performed correctly but it does not show any effect so that user can realize whether button is clicked or not.
Can someone tell me effect which can be realized on click event. I tried on google with css button click effect and tested someof them. But does not make any difference.
Here is css for this:
.uibutton,
.uibutton:visited {
position: relative;
z-index: 1;
overflow: visible;
display: inline-block;
padding: 0.5em 0.8em 0.5em;
border: 1px solid #999;
border-bottom-color: #888;
margin: 0;
text-decoration: none;
text-align: center;
font: bold 13px/normal 'lucida grande', tahoma, verdana, arial, sans-serif;
white-space: nowrap;
cursor: pointer;
/* outline: none; */
color: #333;
background-color: #eee;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f6f6), to(#e4e4e3));
background-image: -moz-linear-gradient(#f5f6f6, #e4e4e3);
background-image: -o-linear-gradient(#f5f6f6, #e4e4e3);
background-image: linear-gradient(#f5f6f6, #e4e4e3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f5f6f6', EndColorStr='#e4e4e3'); /* for IE 6 - 9 */
-webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
-moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #fff;
/* IE hacks */
zoom: 1;
*display: inline;
}
.uibutton:hover,
.uibutton:focus,
.uibutton:active {
border-color: #777 #777 #666;
}
.uibutton:active {
border-color: #aaa;
background: #ddd;
filter: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
/* overrides extra padding on button elements in Firefox */
.uibutton::-moz-focus-inner {
padding: 2.0px;
border: 0;
}
.uibutton.large {
font-size: 16px;
}
/* ............................................................................................................. Submit, etc */
.uibutton.confirm {
border-color: #29447e #29447e #1a356e;
color: #fff;
background-color: #5B74A8;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#637bad), to(#5872a7));
background-image: -moz-linear-gradient(#637bad, #5872a7);
background-image: -o-linear-gradient(#637bad, #5872a7);
background-image: linear-gradient(#637bad, #5872a7);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#637bad', EndColorStr='#5872a7'); /* for IE 6 - 9 */
-webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #8a9cc2;
-moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #8a9cc2;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 #8a9cc2;
}
.uibutton.confirm:active {
border-color: #29447E;
background: #4F6AA3;
filter: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
Sounds a lot like you need css click events. This can be achieved with a simple checkbox.
Here is a link demonstrating it:
http://tympanus.net/Tutorials/CSSClickEvents/index.html
http://jsfiddle.net/Hive7/gd7AJ/
Edit
To do the current element you give the class of css effect to the current element
Edit
Also if you want to make the clicked element change you need to put the checkbox before
Here is a fiddle demo of both:
http://jsfiddle.net/Hive7/gd7AJ/1/

CSS Positioning element relative to grandparent?

I'm trying to position an element (a button) relative to the element 2 elements before it (a picture). There is a varying amount of text between the picture and the button. Take a look at my site:
http://gorilla-gym.com/product-category/fitness-attachments/
What I'm trying to achieve is having the "Shop Now" buttons align horizontally for each product listing regardless of how much text is underneath the picture.
It seemed to me the most logical way to do this way to position the button relative to the picture, but I can't figure out how to do this. Let me know if you guys have an idea of how to do this, or if there's a better way to achieve what I want to do.
Thanks in advance.
check this one i think you want something like this
http://jsfiddle.net/FWzzR/1/
css
ul.products {
display:table;
width:100%;
table-layout:fixed;
border-collapse:separate;
border-spacing:10px;
}
.products > li {
background-color: #4F81BD;
border:2px solid #385D8A;
position: relative;
width: 22.05%;
display: table-cell;
padding:10px;
padding-bottom:50px;
text-align:center;
vertical-align:top;
}
.products > li >a {
display:block;
}
.products a.button {
position:absolute;
bottom:10px;
left:50%;
margin-left:-40px;
font-size: 100%;
line-height: 1em;
cursor: pointer;
text-decoration: none;
padding: 6px 10px;
font-family: inherit;
font-weight: bold;
color: #FFF;
text-shadow: 0 1px 0 #FF6311;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.8);
border: 1px solid #973100;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
background: #FD5200;
background: -webkit-gradient(linear, left top, left bottom, from(#FD5200), to(#CA4100));
background: -webkit-linear-gradient(#FD5200, #CA4100);
background: -moz-linear-gradient(center top, #FD5200 0%, #CA4100 100%);
background: -moz-gradient(center top, #FD5200 0%, #CA4100 100%);
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.075), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: inset 0 -1px 0 rgba(0,0,0,0.075), inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.1);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.075), inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}
If all you want is to center align the "Shop Now" button at the bottom, then
.shopnow_button{
display: block;
margin: 0 auto; //something was overriding so I had to do !important here
width: 57px; // can be any value < the width of the parent container(Ofcourse !)
}
If there is a varying amount of text underneath the picture, then the elements will all be of varying height and you cannot align the "Shop Now" button horizontally beneath the picture. The only way to accomplish this is by making sure that all the divs are the same height, then you just position the shop now button as follows:
<div class="shop-now-div">
<img src="yourimage.jpg">
Lorem ipsum....
<a class="button" href="#">Shop Now</a>
</div>
.button { position: absolute; bottom: 5px; right: 5px; }
.shop-now-div { position: relative; }
There are two ways to make your div's the same height
1) JavaScript (not recommended, it's a pain)
2) A table (do it in CSS so you aren't messing with semantics)
UNFORTUNATELY, some modern browsers (Firefox, I believe) will not support position: relative on table-cell's (which you will need), so you are stuck with having to use JS to make your div's the same height....
Easiest solution:
Stick your shop now button on top of the image - that way you can easily align them horizontally. :)
This question is better answered here How to set relative position with Grandfather! element? simply setting position: relative on the grandfather element and position: absolute on the subject element.
That solution does rely on there being no positioning set on intermediate elements.

Resources