I'm writing a React app, but my question I'm thinking is not about React but about CSS. I have a bar from which the user can choose a sort option:
<div className="innerLineVisor">
<div className="sortLine" ref={lineRef}>
{cuisines.map(cuisine =>
<div key={cuisine.id} className="sortButton">{cuisine.value}</div>
)}
</div>
</div>
Here are their styles:
.innerLineVisor {
width: 80%;
height: 40px;
border: #C80303 1px solid;
overflow: hidden;
position: absolute;
box-sizing: border-box;
left: 10%;
bottom: 0;
}
.sortLine {
height: 40px;
background-color: white;
position: absolute;
left: 0;
bottom: 0;
display: inline;
transition: 1s;
}
.sortButton {
float: left;
width: 120px;
padding: 5px 10px;
border: darkgray 1px solid;
border-radius: 10px;
background-color: white;
margin-top: 5px;
margin-left: 5px;
margin-right: 5px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
box-sizing: border-box;
}
Now when one of the buttons does not fit on the left, I can see part of it. And on the right is empty until the button fits completely.
What can I do to see part of the button on the right as well?
This is the arrow code:
function leftMotion() {
setLimitPositions({...limitPositions, right: false})
if (linePosition + step > 0) {
lineRef.current.setAttribute('style', 'left: 0')
setLinePosition(0)
setLimitPositions({...limitPositions, left: true})
return
}
lineRef.current.setAttribute('style', 'left:' + (linePosition + step) + 'px')
setLinePosition(linePosition + step)
if (limitPositions.left && arrowsPressed.left) {
lineRef.current.setAttribute('style', 'left:' + (linePosition + 10) + 'px')
}
}
function rightMotion() {
setLimitPositions({...limitPositions, left: false})
lineRef.current.setAttribute('style', 'left:' + (linePosition - step) + 'px')
setLinePosition(linePosition - step)
const lineVisorWidth = getLineVisorWidth()
if (lineVisorWidth > (lineLength - (Math.abs(linePosition))) - lineVisorWidth) {
const limitRightPosition = lineLength - lineVisorWidth
lineRef.current.setAttribute('style', 'left:' + (-limitRightPosition) + 'px')
setLinePosition(-limitRightPosition)
setLimitPositions({...limitPositions, right: true})
}
}
Related
help me to achieve the expected result.
i have a grid: the red part.
a nested grid: the blue part.
but im not having lucky implementing this on css. the grid is pretty simple, the roulettes with 50% of the screen, a place to put the numbers with 30% of the screen and a "bank" to store numbers with 20% of the screen.
the problem here is the nested grid. in each side of the nested grid should be a roullete, wheel and spin. they should mantain the 1:1 square aspect ratio and scale with the window. but they arent even sticking to the grid.
here is an image of the expected result:
and here is what i get so far:
const sectors = [{
color: "#f82",
label: "Stack"
},
{
color: "#0bf",
label: "10"
},
{
color: "#fb0",
label: "200"
},
{
color: "#0fb",
label: "50"
},
{
color: "#b0f",
label: "100"
},
{
color: "#f0b",
label: "5"
},
{
color: "#bf0",
label: "500"
},
];
const rand = (m, M) => Math.random() * (M - m) + m;
const tot = sectors.length;
const EL_spin = document.querySelector("#spin");
const ctx = document.querySelector("#wheel").getContext('2d');
const dia = ctx.canvas.width;
const rad = dia / 2;
const PI = Math.PI;
const TAU = 2 * PI;
const arc = TAU / sectors.length;
const friction = 0.991; // 0.995=soft, 0.99=mid, 0.98=hard
let angVel = 0; // Angular velocity
let ang = 0; // Angle in radians
const getIndex = () => Math.floor(tot - ang / TAU * tot) % tot;
function drawSector(sector, i) {
const ang = arc * i;
ctx.save();
// COLOR
ctx.beginPath();
ctx.fillStyle = sector.color;
ctx.moveTo(rad, rad);
ctx.arc(rad, rad, rad, ang, ang + arc);
ctx.lineTo(rad, rad);
ctx.fill();
// TEXT
ctx.translate(rad, rad);
ctx.rotate(ang + arc / 2);
ctx.textAlign = "right";
ctx.fillStyle = "#fff";
ctx.font = "bold 30px sans-serif";
ctx.fillText(sector.label, rad - 10, 10);
//
ctx.restore();
};
function rotate() {
const sector = sectors[getIndex()];
ctx.canvas.style.transform = `rotate(${ang - PI / 2}rad)`;
EL_spin.textContent = !angVel ? "SPIN" : sector.label;
EL_spin.style.background = sector.color;
}
function frame() {
if (!angVel) return;
angVel *= friction; // Decrement velocity by friction
if (angVel < 0.002) angVel = 0; // Bring to stop
ang += angVel; // Update angle
ang %= TAU; // Normalize angle
rotate();
}
function engine() {
frame();
requestAnimationFrame(engine)
}
// INIT
sectors.forEach(drawSector);
rotate(); // Initial rotation
engine(); // Start engine
EL_spin.addEventListener("click", () => {
if (!angVel) angVel = rand(0.25, 0.35);
});
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.grid {
display: grid;
grid-template-rows: 50vh 30vh 20vh;
}
.roulettes {
display: grid;
grid-template-columns: 50fr 50fr;
}
#roulette {
display: inline-block;
position: relative;
overflow: hidden;
}
#wheel {
display: block;
}
#spin {
font: 1.5em/0 sans-serif;
user-select: none;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 50%;
left: 50%;
width: 30%;
height: 30%;
margin: -15%;
background: #fff;
color: #fff;
box-shadow: 0 0 0 8px currentColor, 0 0px 15px 5px rgba(0, 0, 0, 0.6);
border-radius: 50%;
transition: 0.8s;
}
#spin::after {
content: "";
position: absolute;
top: -17px;
border: 10px solid transparent;
border-bottom-color: currentColor;
border-top: none;
}
#op_roulette {
display: inline-block;
position: relative;
overflow: hidden;
}
#op_wheel {
display: block;
}
#op_spin {
font: 1.5em/0 sans-serif;
user-select: none;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 50%;
left: 50%;
width: 30%;
height: 30%;
margin: -15%;
background: #fff;
color: #fff;
box-shadow: 0 0 0 8px currentColor, 0 0px 15px 5px rgba(0, 0, 0, 0.6);
border-radius: 50%;
transition: 0.8s;
}
#op_spin::after {
content: "";
position: absolute;
top: -17px;
border: 10px solid transparent;
border-bottom-color: currentColor;
border-top: none;
}
<body>
<div class="grid" width="100vw" height="100vh">
<div class="roulettes">
<div id="roulette">
<canvas id="wheel" width="300%" height="300%"></canvas>
<div id="spin">SPIN</div>
</div>
<div id="op_roullete">
<canvas id="op_wheel" width="300%" height="300%"></canvas>
<div id="op_spin">SPIN</div>
</div>
</div>
<div id="operation">=</div>
<div id="bank">BANK</div>
</div>
</body>
PS. (the will is made by https://stackoverflow.com/users/383904/roko-c-buljan) i know that the wheel is draw by js, and it only draws in the wheel element. once i get the grid right i will change the code to draw a wheel on the op_wheel element too, so this is not a problem.
Trying to make these gooey CSS moving blobs. The basic setup seems to be that you give the circles blur and then add contrast to their container. The issue is that whenever I do that with custom colors the entire element just disappears. I tried it on these demos and same thing. Does anyone know why or know a workaround?
Here is a tutorial I've been following:
https://css-tricks.com/shape-blobbing-css/
Here is the code:
$(document).ready(function() {
$(".dot").hover(function() {
var cur = $(this);
var dest = cur.position().left;
var t = 0.6;
TweenMax.to($(".select"), t, {
x: dest,
ease: Back.easeOut
})
});
var lastPos = $(".select").position().left;
function updateScale() {
var pos = $(".select").position().left;
var speed = Math.abs(pos - lastPos);
var d = 44;
var offset = -20;
var hd = d / 2;
var scale = (offset + pos) % d;
if (scale > hd) {
scale = hd - (scale - hd);
}
scale = 1 - ((scale / hd) * 0.35);
TweenMax.to($(".select"), 0.1, {
scaleY: scale,
scaleX: 1 + (speed * 0.06)
})
lastPos = pos;
requestAnimationFrame(updateScale);
}
requestAnimationFrame(updateScale);
$(".dot:eq(0)").trigger("mouseover");
})
.text {
position: relative;
left: 110px;
top: 10px;
font-family: 'Baskerville', Georgia, serif;
font-size: 17px;
}
a {
color: inherit;
}
.dots {
list-style-type: none;
background: white;
-webkit-filter: blur(5px) contrast(10);
padding: 0;
margin: 0;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
margin-left: -10px;
padding-right: 10px;
position: relative;
left: 100px;
top: 30px;
}
.dot {
display: inline-block;
vertical-align: middle;
border-radius: 100%;
width: 30px;
height: 30px;
background: black;
margin-left: 5px;
margin-right: 5px;
cursor: pointer;
color: white;
position: relative;
z-index: 2;
}
.select {
display: block;
border-radius: 100%;
width: 40px;
height: 40px;
background: black;
//opacity:0.6;
//transition:transform 300ms ease-in-out;
position: absolute;
z-index: 3;
top: 15px;
left: 0px;
pointer-events: none;
}
<div class="text">
<h1>Gooey pagination</h1>
Based on a dribbble by Kreativa Studio. <br />
Made by Lucas Bebber. <br /> <br />
Hover on the dots bellow
</div>
<ul class="dots">
<li class="select"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.13.1/TweenMax.min.js"></script>
If you go to one of their demos and try changing the color to something like pink or #A0D9A8 you'll see what I mean:
This is really interresting. It seems that to work the color must cause a very strong contrast because of the filter rule used. So you will have to use flashy colors to make them appear. The colors pink or #A0D9A8 aren't flashy enought for the blur that's going to make him disappear. So try to use more flashy colors like #e83ce8 that's like a pink color:
$(document).ready(function() {
$(".dot").hover(function() {
var cur = $(this);
var dest = cur.position().left;
var t = 0.6;
TweenMax.to($(".select"), t, {
x: dest,
ease: Back.easeOut
})
});
var lastPos = $(".select").position().left;
function updateScale() {
var pos = $(".select").position().left;
var speed = Math.abs(pos - lastPos);
var d = 44;
var offset = -20;
var hd = d / 2;
var scale = (offset + pos) % d;
if (scale > hd) {
scale = hd - (scale - hd);
}
scale = 1 - ((scale / hd) * 0.35);
TweenMax.to($(".select"), 0.1, {
scaleY: scale,
scaleX: 1 + (speed * 0.06)
})
lastPos = pos;
requestAnimationFrame(updateScale);
}
requestAnimationFrame(updateScale);
$(".dot:eq(0)").trigger("mouseover");
})
.text {
position: relative;
left: 110px;
top: 10px;
font-family: 'Baskerville', Georgia, serif;
font-size: 17px;
}
a {
color: inherit;
}
.dots {
list-style-type: none;
background: white;
-webkit-filter: blur(5px) contrast(10);
padding: 0;
margin: 0;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
margin-left: -10px;
padding-right: 10px;
position: relative;
left: 100px;
top: 30px;
}
.dot {
display: inline-block;
vertical-align: middle;
border-radius: 100%;
width: 30px;
height: 30px;
background: #e83ce8;
margin-left: 5px;
margin-right: 5px;
cursor: pointer;
color: white;
position: relative;
z-index: 2;
}
.select {
display: block;
border-radius: 100%;
width: 40px;
height: 40px;
background: #e83ce8;
position: absolute;
z-index: 3;
top: 15px;
left: 0px;
pointer-events: none;
}
<div class="text">
<h1>Gooey pagination</h1>
Based on a dribbble by Kreativa Studio. <br />
Made by Lucas Bebber. <br /> <br />
Hover on the dots bellow
</div>
<ul class="dots">
<li class="select"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.13.1/TweenMax.min.js"></script>
Check what it says on the entire page over on CSS tricks, about brightness especially.
You just need to change the following and you will see pink blorbs.
.dots{
...
-webkit-filter: blur(5px) contrast(10) brightness(-50);
...
}
.dot {
...
background: /* black */ pink;
...
}
.select { /* EDIT */
...
background: /* black */ pink;
...
}
EDIT: I used a CSS variable in this fiddle:
https://jsfiddle.net/p97qxzew/
I am trying to create a custom cursor that changes when hovering over a <div>, but there is a flicker when moving left to right across it, but not when moving right to left. Why this is happening and what I can do to fix it?
document.addEventListener('mousemove', (ev) => cursorMove(ev));
function cursorMove(ev) {
let circle = document.getElementById('circle');
let posY = ev.clientY;
let posX = ev.clientX;
circle.style.top = posY + 'px';
circle.style.left = posX + 'px';
}
body {
margin: 0;
height: 100vh;
background-color: #acd1d2;
position: relative;
display: flex;
justify-content: center;
align-items: center;
font-family: monospace;
}
#wrapper {
position: relative;
width: 70%;
height: 80%;
}
.box {
height: 25%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
#box-1 {
background-color: #e8edf3;
}
#box-1:hover ~ #circle {
background-color: #e6cf8b;
box-shadow:inset 0em -0.3em 0.4em 0.2em #ca9e03a6;
}
#box-2 {
background-color: #e6cf8b;
}
#box-2:hover ~ #circle {
background-color: transparent;
border: 3px solid #E91E63;
}
#box-3 {
background-color: #b56969;
}
#box-3:hover ~ #circle {
height: 1em;
width: 1em;
background-color: #e6cf8b;
}
#box-4 {
background-color: #22264b;
color: white;
}
#box-4:hover ~ #circle {
background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
}
#circle {
position: fixed;
border-radius: 50%;
z-index: 5;
height: 32px;
width: 32px;
background-color: white;
}
<div id="wrapper">
<div id="box-1" class="box">Sphere</div>
<div id="box-2" class="box">Circle outline</div>
<div id="box-3" class="box">Circle pin</div>
<div id="box-4" class="box">Circle color gradient</div>
<div id="circle"></div>
</div>
That's because your mouse moves faster than the circle and you hover over it, so the styles that apply to it are the same ones than when the cursor is on the background green/blue-ish area of the page.
You can fix that by adding pointer-events: none to the circle so that it feels a bit like this:
Ok, where were we? Oh yes... So you should use position: fixed instead of absolute (as you really want your cursor to be positioned relative to the top-left corner of the viewport) and probably window.requestAnimationFrame to get a smoother animation and translate3d(0, 0, 0) to promote the element to its own layer and enable hardware-accelerated rendering, which will also contribute to make it feel smoother.
You could also hide the default cursor with cursor: none and center the circle where the arrowhead of the cursor is to make it feel just like a real cursor.
const circle = document.getElementById('circle');
const circleStyle = circle.style;
document.addEventListener('mousemove', e => {
window.requestAnimationFrame(() => {
circleStyle.top = `${ e.clientY - circle.offsetHeight/2 }px`;
circleStyle.left = `${ e.clientX - circle.offsetWidth/2 }px`;
});
});
body {
margin: 0;
height: 100vh;
background-color: #acd1d2;
position: relative;
display: flex;
justify-content: center;
align-items: center;
font-family: monospace;
cursor: none;
}
#wrapper {
position: relative;
width: 70%;
height: 80%;
}
#circle {
position: fixed;
border-radius: 50%;
z-index: 5;
height: 32px;
width: 32px;
background-color: white;
pointer-events: none;
transition:
background ease-in 10ms,
box-shadow ease-in 150ms,
transform ease-in 150ms;
/* Promote it to its own layer to enable hardware accelerated rendering: */
transform: translate3d(0, 0, 0);
}
.box {
height: 25%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
#box-1 {
background-color: #e8edf3;
}
#box-1:hover ~ #circle {
background-color: #e6cf8b;
box-shadow: 0 0 0 0 transparent, inset 0em -0.3em 0.4em 0.2em #ca9e03a6;
}
#box-2 {
background-color: #e6cf8b;
}
#box-2:hover ~ #circle {
background-color: transparent;
/* Use box-shadow instead of border to avoid changing the dimensions of the
cursor, which will make it be off-center until the mouse moves again: */
aborder: 3px solid #E91E63;
box-shadow: 0 0 0 3px #E91E63;
}
#box-3 {
background-color: #b56969;
}
#box-3:hover ~ #circle {
background-color: #e6cf8b;
/* Change its size with scale() instead of width and height for better
performance performance: */
transform: scale(0.5) translate3d(0, 0, 0);
}
#box-4 {
background-color: #22264b;
color: white;
}
#box-4:hover ~ #circle {
background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
}
<div id="wrapper">
<div id="box-1" class="box">Sphere</div>
<div id="box-2" class="box">Circle outline</div>
<div id="box-3" class="box">Circle pin</div>
<div id="box-4" class="box">Circle color gradient</div>
<div id="circle"></div>
</div>
Here you can see another cool example I made of a custom cursor using CSS that resembles a torch: How to darken a CSS background image but keep area around cursor brighter.
Also, you can check out the cursor on my website, which is quite similar to what you have done as it has animations/transitions between its different shapes or states.
🚀 Check it out here: https://gmzcodes.com/.
👨💻 Check the code here: https://github.com/Danziger/gmzcodes
I'm using a pure CSS tooltip on this page: http://theroadmap.co/generation/
On small screen, hovering over some longer tooltips on right column causes tooltip to go off screen. Is there any way to get it to wrap when it reaches right end of screen?
Here is code for the tooltip:
/* TOOLTIP TIME */
.tooltip {
position: relative;
text-decoration: none;
}
.tooltip:hover:before {
display: block;
position: absolute;
padding: .5em;
content: attr(href);
min-width: 120px;
text-align: center;
width: auto;
height: auto;
white-space: nowrap;
top: -32px;
background: rgba(0,0,0,.8);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
color: #fff;
font-size: 1.2em;
z-index: 1000;
}
.tooltip:hover:after {
position: absolute;
display: block;
content: "";
border-color: rgba(0,0,0,.8) transparent transparent;
border-style: solid;
border-width: 10px;
height: 0;
width: 0;
position: absolute;
top: -8px;
left: 1em;
}
var mousex = e.pageX + 20; //Get X coordinates
var mousey = e.pageY + 10; //Get Y coordinates
if((mousey+100)>$(window).height())
{
$('.tooltip')
.css({ top: mousey-100 ,left: mousex })
}
else if((mousex+200)>$(window).width())
{
$('.tooltip')
.css({ top: mousey ,left: mousex-200})
}
else
{
$('.tooltip')
.css({ top: mousey, left: mousex })
}
i had the same problem when i tried to display a file name. seems like the name was too long and there weren't any spaces in it, so i used
word-break: break-all;
in my .tooltip class.
this is my funtion for tooltip:
$('.file_attachments').hover(function () {
var tooltip = '<div class="tooltip"></div>';
// Hover over code
var title = $.trim($(this).attr('title'));
if (title.length > 0) {
$(this).data('tipText', title).removeAttr('title');
$('body').append(tooltip);
$('.tooltip').html(title);
$('.tooltip').fadeIn('slow');
} else {
$('body').append(tooltip);
}
}, function () {
// Hover out code
$(this).attr('title', $(this).data('tipText'));
$('.tooltip').remove();
}).mousemove(function (e) {
var mousex = e.pageX + 20; //Get X coordinates
var mousey = e.pageY + 10; //Get Y coordinates
$('.tooltip').css({top: mousey, left: mousex})
});
I've been trying to apply carets to input-group elements in Bootstrap 3. Failing so far. Tried using table-cell display for the inserted pseudo element, tried absolute positioning, tried using the content property to display a web font caret instead of my preferred CSS triangle caret. Just can't wrap my head around this one.
Here's a JSFiddle (the red borders being where I'd expect the caret to show).
.input-group .input-group-addon:last-child:before,
.input-group .input-group-btn:last-child:before,
.input-group .input-group-addon:not(:last-child):before,
.input-group .input-group-btn:not(:last-child):before {
position: absolute;
content: '';
width: 0;
height: 0;
border: 10px solid transparent;
margin: auto;
top: 0;
bottom: 0;
z-index: 1000;
}
.input-group .input-group-addon:last-child:before,
.input-group .input-group-btn:last-child:before {
border-right-color: red;
right: 0;
}
.input-group .input-group-addon:not(:last-child):before,
.input-group .input-group-btn:not(:last-child):before {
border-left-color: red;
left: 0;
}
EDIT : Based on an answer, I modified the styles which now work fine in all but IE10 and below. IE offsets left-aligned input-group carets by 4px as can be seen here http://jsfiddle.net/W8mFS/3/. Any ideas how to fix this up?
The updated CSS:
.input-group.input-group-caret span:after,
.input-group.input-group-caret > input + span:before {
position: absolute;
content: '';
width: 0;
height: 0;
top: 0;
bottom: 0;
margin: auto;
border: 10px solid transparent;
}
.input-group.input-group-caret > input + span:before {
border-right-color: #cccccc;
margin-left: -20px;
}
.input-group.input-group-caret > input + span:empty:before {
margin-left: -44px;
}
.input-group.input-group-caret > input + span:after {
border-left-color: transparent;
}
.input-group.input-group-caret span:after {
border-left-color: #cccccc;
}
.input-group.input-group-caret .input-group-addon {
padding: 0;
}
.input-group.input-group-caret .input-group-addon i {
font-style: normal;
margin-left: 12px;
padding-right: 12px;
}
.input-group.input-group-caret .input-group-addon:empty {
padding-left: 24px;
}
UPDATE : With added input-group sizing JSFiddle here: http://jsfiddle.net/W8mFS/4/.
The LESS code shows the use of Bootstrap variables to control caret size, margins and padding:
#import "path_to_bootstrap/less/mixins";
#import "path_to_bootstrap/less/variables";
// input-group caret size
#caret-size-base: ceil(#font-size-base * 0.70); // ~10px;
#caret-size-large: ceil(#caret-size-base * 1.20); // ~12px;
#caret-size-small: ceil(#caret-size-base * 0.80); // ~8px;
// input-group caret
.input-group.input-group-caret {
span:after,
> input + span:before {
position: absolute;
content: '';
width: 0;
height: 0;
// v-align to middle
top: 0;
bottom: 0;
margin: auto;
border: #caret-size-base solid transparent;
}
> input + span:before { border-right-color: #input-border; margin-left: -( 2 * #caret-size-base ); } // right aligned
> input + span:empty:before { margin-left: -(( 2 * #padding-base-horizontal ) + ( 2 * #caret-size-base )); } // right aligned
> input + span:after { border-left-color: transparent; } // right aligned
span:after { border-left-color: #input-border; } // left aligned
// sizing
&.input-group-sm {
span:after,
> input + span:before {
border: #caret-size-small solid transparent;
}
> input + span:before { border-right-color: #input-border; margin-left: -( 2 * #caret-size-small ); } // right aligned
> input + span:empty:before { margin-left: -(( 2 * #padding-base-horizontal ) + ( 2 * #caret-size-small )); } // right aligned
> input + span:after { border-left-color: transparent; } // right aligned
span:after { border-left-color: #input-border; } // left aligned
}
&.input-group-lg {
span:after,
> input + span:before {
border: #caret-size-large solid transparent;
}
> input + span:before { border-right-color: #input-border; margin-left: -( 2 * #caret-size-large ); } // right aligned
> input + span:empty:before { margin-left: -(( 2 * #padding-base-horizontal ) + ( 2 * #caret-size-large )); } // right aligned
> input + span:after { border-left-color: transparent; } // right aligned
span:after { border-left-color: #input-border; } // left aligned
}
// input-group caret alignment fixes
.input-group-addon {
padding: 0;
i {
font-style: normal;
margin-left: #padding-base-horizontal;
padding-right: #padding-base-horizontal;
}
// fix-up alignment of empty addon
&:empty {
padding-left: 2 * #padding-base-horizontal;
}
}
}
It seems .input-group > input + span:before will be a good selector for Right Aligned. But there will also be the problem that box-sizing : border-box (Why did Bootstrap 3 switch to box-sizing: border-box?) breaks the carets / forms. (width include :after and :before too?)
see: http://bootply.com/83702
.input-group > input + span:before {
display: inline-block;
width: 0;
height: 0;
border-right: 10px solid red;
border-top: 10px solid transparent;
border-left: 0 dotted;
border-bottom: 10px solid transparent;
vertical-align: middle;
margin-left: 2px;
content:'';
}