for a form I'm creating, I used css to display radio buttons as a toggle-switch.
However its not responsive at all. When viewing on mobile the "scale" 1-5 is broken up in pieces. My goal is to change the with of the scale responsively instead of it breaking up.
Somehow I can't seem to figure it out.
Here's the code: http://jsfiddle.net/7byse1vk/
.toggle__label {
transition: all .25s ease;
display: inline-block;
border-radius: 5px;
background-color: #878787;
cursor: pointer;
padding: 0 30px;
min-width: 100px;
height: 48px;
line-height: 48px;
color: #a7a6ae;
text-align: center;
}
Many thanks in advance!
You can use display: flex; on the parent, remove the min-width from the labels (otherwise that will make them at least 160px wide each, too wide for mobile), and set them to flex-grow: 1 so they fill the parent fluidly.
body {
padding: 20px;
}
.toggle {
margin-bottom: 20px;
}
.row {
display: flex;
}
.toggle__label {
transition: all .25s ease;
border-radius: 5px;
background-color: #878787;
cursor: pointer;
padding: 0 30px;
height: 48px;
line-height: 48px;
color: #a7a6ae;
text-align: center;
flex-grow: 1;
}
.toggle__input:checked + .toggle__label {
background-color: #e5702a;
color: white;
}
.toggle__label--left {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.toggle__label--middle {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
margin-left: -4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.toggle__label--right {
margin-left: -4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.toggle__input {
position: absolute;
left: -99999px;
}
label {
padding: 0.4em 2em 0.4em 0;
}
.toggle-btn-grp {
margin: 3px 0;
}
.toggle-btn {
text-align: centre;
margin: 5px 2px;
padding: 0.4em 3em;
color: #000;
background-color: #FFF;
border-radius: 10px;
display: inline-block;
border: solid 1px #CCC;
cursor: pointer;
}
.toggle-btn-grp.joint-toggle .toggle-btn {
margin: 5px 0;
padding: 0.4em 2em;
border-radius: 0;
border-right-color: white;
}
.toggle-btn-grp.joint-toggle .toggle-btn:first-child {
margin-left: 2px;
border-radius: 10px 0px 0px 10px;
}
.toggle-btn-grp.joint-toggle .toggle-btn:last-child {
margin-right: 2px;
border-radius: 0px 10px 10px 0px;
border-right: solid 1px #CCC;
}
.toggle-btn:hover {
border: solid 1px #a0d5dc !important;
background: #f1fdfe;
}
.toggle-btn.success {
background: lightgreen;
border: solid 1px green !important;
}
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
/* CSS only version */
.toggle-btn-grp.cssonly * {
width: 140px;
height: 30px;
line-height: 30px;
}
.toggle-btn-grp.cssonly div {
display: inline-block;
position: relative;
margin: 5px 2px;
}
.toggle-btn-grp.cssonly div label {
position: absolute;
z-index: 0;
padding: 0;
text-align: center;
}
.toggle-btn-grp.cssonly div input {
position: absolute;
z-index: 1;
cursor: pointer;
opacity: 0;
}
.toggle-btn-grp.cssonly div:hover label {
border: solid 1px #a0d5dc !important;
background: #f1fdfe;
}
.toggle-btn-grp.cssonly div input:checked + label {
background: lightgreen;
border: solid 1px green !important;
}
<div class="row">
<input class="toggle__input" id="option-1" type="radio" name="input4" value="1">
<label class="toggle__label toggle__label--left" for="option-1">1</label>
<input checked="true" class="toggle__input" id="option-2" type="radio" name="input4" value="2">
<label class="toggle__label toggle__label--middle" for="option-2">2</label>
<input class="toggle__input" id="option-3" type="radio" name="input4" value="3">
<label class="toggle__label toggle__label--middle" for="option-3">3</label>
<input class="toggle__input" id="option-4" type="radio" name="input4" value="4">
<label class="toggle__label toggle__label--middle" for="option-4">4</label>
<input class="toggle__input" id="option-5" type="radio" name="input4" value="5">
<label class="toggle__label toggle__label--right" for="option-5">5</label>
</div>
Replace your CSS for the labels below and it'll work. This will scale them down properly. It's because at the moment they've got a minimum set width and are being stretch with the padding because they don't have box-sizing: border-box;.
.toggle__label {
transition: all .25s ease;
display: inline-block;
border-radius: 5px;
background-color: #878787;
cursor: pointer;
padding: 0 30px;
width: 20%;
height: 48px;
line-height: 48px;
color: #a7a6ae;
text-align: center;
float: left;
box-sizing: border-box;
}
Related
In my project I am using some CSS code to create a floating label for my form inputs. The original code for the floating label can be found here for reference.
However since this code contains a number of floating label examples I have extracted the compiled CSS for the one I am interested in (balloon) and created an example below with my modifications. Specifically I have added a value to the input fields.
.balloon {
display: inline-block;
width: 600px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px;
transition: all .3s ease-in-out;
}
.balloon::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}
.balloon + label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122, 184, 147, 0);
}
.balloon + label:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122, 184, 147, 0);
transition: all .3s ease-in-out;
}
.balloon:focus,
.balloon:active {
color: #377D6A;
text-indent: 0;
background: #fff;
}
.balloon:focus::-webkit-input-placeholder,
.balloon:active::-webkit-input-placeholder {
color: #aaa;
}
.balloon:focus + label,
.balloon:active + label {
color: #fff;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #7ab893;
transform: translateY(-40px);
}
.balloon:focus + label:after,
.balloon:active + label:after {
border-top: 4px solid #7ab893;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
position: relative;
z-index: 1;
text-align: center;
}
.row:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
background: inherit;
}
.row:first-child {
padding: 40px 30px;
}
.row span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
<div class="row">
<span>
<input class="balloon" id="state" type="text" value="AR" placeholder="Liquid, solid, gaseous..." /><label for="state">State</label>
</span>
<span>
<input class="balloon" id="planet" value="Earth" type="text" placeholder="Probably Earth" /><label for="planet">Planet</label>
</span>
<span>
<input class="balloon" id="galaxy" type="text" value="This is a test" placeholder="Milky Way?" /><label for="galaxy">Guardians of the Galaxy</label>
</span>
</div>
The question I have, if you look at the third input, is how to adjust spacing for the label so they dont overlap. I realize that I can change the text-indent in the balloon class but that will change the spacing for all the inputs.
Is there a way on an individual basis I can adjust the spacing to account for different lengths in labels?
Add an extra class to "Gardians" and style that to have a little more with.
Then (and I can't believe I'm about to say this) use !important on the active text-indent to overcome the extra specificity of the new class.
.balloon {
display: inline-block;
width: 600px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px;
transition: all .3s ease-in-out;
}
/*Wide Version - can be applied to more elements*/
.balloon.wide {
text-indent: 200px;
}
.balloon::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}
.balloon + label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122, 184, 147, 0);
}
.balloon + label:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122, 184, 147, 0);
transition: all .3s ease-in-out;
}
.balloon:focus,
.balloon:active {
color: #377D6A;
/*Note !important*/
text-indent: 0 !important;
background: #fff;
}
.balloon:focus::-webkit-input-placeholder,
.balloon:active::-webkit-input-placeholder {
color: #aaa;
}
.balloon:focus + label,
.balloon:active + label {
color: #fff;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #7ab893;
transform: translateY(-40px);
}
.balloon:focus + label:after,
.balloon:active + label:after {
border-top: 4px solid #7ab893;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
position: relative;
z-index: 1;
text-align: center;
}
.row:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
background: inherit;
}
.row:first-child {
padding: 40px 30px;
}
.row span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
<div class="row">
<span>
<input class="balloon" id="state" type="text" value="AR" placeholder="Liquid, solid, gaseous..." /><label for="state">State</label>
</span>
<span>
<input class="balloon" id="planet" value="Earth" type="text" placeholder="Probably Earth" /><label for="planet">Planet</label>
</span>
<span>
<input class="balloon wide" id="galaxy" type="text" value="This is a test" placeholder="Milky Way?" /><label for="galaxy">Guardians of the Galaxy</label>
</span>
</div>
I normally avoid !important like the plague but in this case it makes sense. You could avoid it by using more specific selectors for your active state
.balloon:focus,
.balloon:active,
.balloon.wide:focus,
.balloon.wide:active, {
color: #377D6A;
text-indent: 0;
background: #fff;
}
target the input value
input[value="This is a test"] {text-indent:170px; }
.balloon {
display: inline-block;
width: 600px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px;
transition: all .3s ease-in-out;
}
.balloon::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}
.balloon + label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122, 184, 147, 0);
}
.balloon + label:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122, 184, 147, 0);
transition: all .3s ease-in-out;
}
.balloon:focus,
.balloon:active {
color: #377D6A;
text-indent: 0;
background: #fff;
}
.balloon:focus::-webkit-input-placeholder,
.balloon:active::-webkit-input-placeholder {
color: #aaa;
}
.balloon:focus + label,
.balloon:active + label {
color: #fff;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #7ab893;
transform: translateY(-40px);
}
.balloon:focus + label:after,
.balloon:active + label:after {
border-top: 4px solid #7ab893;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
position: relative;
z-index: 1;
text-align: center;
}
.row:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
background: inherit;
}
.row:first-child {
padding: 40px 30px;
}
.row span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
<div class="row">
<span>
<input class="balloon" id="state" type="text" value="AR" placeholder="Liquid, solid, gaseous..." /><label for="state">State</label>
</span>
<span>
<input class="balloon" id="planet" value="Earth" type="text" placeholder="Probably Earth" /><label for="planet">Planet</label>
</span>
<span>
<input class="balloon" id="galaxy" type="text" value="This is a test" placeholder="Milky Way?" /><label for="galaxy">Guardians of the Galaxy</label>
</span>
</div>
I'm trying to change the style of a input only if the input is focused and the sibling is hovered like so:
form#search {
display: inline-block;
position: relative;
min-width: 305px;
height: 2.500em;
width: 100%;
margin: 10px 20px;
vertical-align: middle;
}
form#search input {
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
height: 100%;
width: 100%;
padding: 0.5em 5.33em 0.6em 0.33em;
margin: 0 -2px 0 0;
border: 2px solid #f2f2f2;
}
form#search input:hover,
form#search input:focus {
border: 2px solid #005785;
outline: none;
}
form#search button {
position: absolute;
right: 0px;
width: 5em;
height: 100%;
background-color: #005785;
color: #fff;
margin: 10px auto;
padding: 0.33em 1em 0.33em 1em;
outline: none;
border: none;
margin: 0;
cursor: pointer;
}
form#search button:hover,
form#search button:focus {
background-color: #003550;
}
form#search input:focus ~ button:hover ~ input:focus {
border: 2px solid #003550 !important;
}
<form id="search">
<input type="text">
<button type="submit">Search</button>
</form>
More specifically this line:
form#search input:focus ~ button:hover ~ input:focus
Anyone have any idea how to fix this? It doesn't appear to work and I have no idea as the logic seems sound.
Thanks,
Jamie
The general sibling selector (~) will only search forward in the DOM.
To achieve your desired result you would have to rearrange the order of the button and input.
Your selector would then become:
form#search button:hover ~ input:focus
Since there are only two elements, you could use the immediate sibling selector (+) instead:
form#search button:hover + input:focus
form#search {
display: inline-block;
position: relative;
min-width: 305px;
height: 2.500em;
width: 100%;
margin: 10px 20px;
vertical-align: middle;
}
form#search input {
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
height: 100%;
width: 100%;
padding: 0.5em 5.33em 0.6em 0.33em;
margin: 0 -2px 0 0;
border: 2px solid #f2f2f2;
}
form#search input:hover,
form#search input:focus {
border: 2px solid #005785;
outline: none;
}
form#search button {
position: absolute;
right: 0px;
width: 5em;
height: 100%;
background-color: #005785;
color: #fff;
margin: 10px auto;
padding: 0.33em 1em 0.33em 1em;
outline: none;
border: none;
margin: 0;
cursor: pointer;
z-index: 1;
}
form#search button:hover,
form#search button:focus {
background-color: #003550;
}
form#search button:hover ~ input:focus {
border: 2px solid red !important;
}
<form id="search">
<button type="submit">Search</button>
<input type="text">
</form>
I've also added a z-index to the button to place it in front of the input.
I am using material web components in my project, as well as an algolia autocomplete.js. I have made a search input field where I would like to show the results in an autocomplete dropdown menu. This is the html:
<form action="/search" method="get">
<div class="mdc-text-field mdc-text-field--box mdc-text-field--with-leading-icon">
<i class="material-icons mdc-text-field__icon" tabindex="0">search</i>
<input name="q"
type="text"
class="mdc-text-field__input search-input-js aa-input-search"
placeholder="Search for players and videos ..."
aria-label="Full-Width Text Field">
</div>
</form>
And this is the css:
.algolia-autocomplete {
display: flex!important;
flex: auto!important;
height: 100%;
}
.aa-dropdown-menu {
position: relative;
top: -6px;
border-radius: 3px;
margin: 6px 0 0;
padding: 0;
text-align: left;
height: auto;
position: relative;
background: $white;
border: 1px solid #ccc;
width: 100%;
left: 0 !important;
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1);
}
.aa-dropdown-menu:before {
position: absolute;
content: '';
width: 14px;
height: 14px;
background: #fff;
z-index: 0;
top: -7px;
border-top: 1px solid #D9D9D9;
border-right: 1px solid #D9D9D9;
transform: rotate(-45deg);
border-radius: 2px;
z-index: 999;
display: block;
left: 24px;
}
.aa-dropdown-menu .aa-suggestions {
position: relative;
z-index: 1000;
}
.aa-dropdown-menu [class^="aa-dataset-"] {
position: relative;
border: 0;
border-radius: 3px;
overflow: auto;
padding: 8px 8px 8px;
color: #3c3e42;
font-weight: 500;
}
.aa-dropdown-menu * {
box-sizing: border-box;
}
.aa-suggestion {
padding: 0 4px 0;
display: block;
width: 100%;
height: 38px;
clear: both;
}
.aa-suggestion span {
white-space: nowrap !important;
text-overflow: ellipsis;
overflow: hidden;
display: block;
float: left;
line-height: 1em;
width: calc(100% - 30px);
}
.aa-suggestion.aa-cursor {
background-color: transparent;
}
.aa-suggestion em {
color: #00bcd4;
font-weight: 700;
}
.aa-suggestion img {
float: left;
height: 44px;
width: 44px;
margin-right: 6px;
}
.aa-suggestion a {
color: #3c3e42;
}
.aa-suggestions-category {
font-weight: 700;
color: #3c3e42;
border-bottom: 1px solid rgba(102, 105, 105, 0.17);
}
.powered-by-algolia {
padding-left: 15px;
border-top: 1px solid rgba(102, 105, 105, 0.17);
display: flex;
align-items: center;
height: 30px;
}
.aa-input-container {
display: inline-block;
position: relative; }
.aa-input-search {
width: 100%;
height: 30px;
padding: 12px 28px 12px 12px;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none; }
.aa-input-search::-webkit-search-decoration, .aa-input-search::-webkit-search-cancel-button, .aa-input-search::-webkit-search-results-button, .aa-input-search::-webkit-search-results-decoration {
display: none;
}
.media {
margin: 10px 0;
}
.media-body {
p {
margin: 0;
}
}
The problem I have is that the dropdown menu is not visible with the mdc-text-field--box if I am not using the box field and I am instead using the normal field then the dropdown menu is visible. How can I fix this so that the dropdown menu is also visible with the mdc-text-field--box?
You should update the CSS in order to override the overflow on .mdc-text-field--box and update the pseudo elements.
.mdc-text-field--box {
overflow: visible;
}
.mdc-text-field--box:after,
.mdc-text-field--box:before {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
You can find an example on the jsFiddle also.
Please refer to this image as a visual aid for my question.
I want the text input with "Sindre", the other input, and the buttons, to be placed higher, so they vertically align with the Icehotel logo. How can I do this?
Here's my code...
HTML
<div id="header-content">
<br>
<a href="/index">
<img draggable="false" src="{url}/app/tpl/skins/{skin}/images/logo.gif" style="position:relative; margin-left: 20px; <div align=; color: #FA0000;margin-top: 15px;margin-left: 180px">
</a>
<input id="username" name="log_username" placeholder="Username" style="position:relative; margin-left: 20px;padding:5px;box-shadow:3px 3px 5px black;border: 0;width:250px;background: #3b8ba4;border-radius: 6px;color: #baedf5;" type="text">
<input id="password" name="log_password" placeholder="Password" style="position:relative;margin-left: 1px;padding:5px;box-shadow:3px 3px 5px black;border: 0;width:250px;background: #3b8ba4;border-radius: 6px;color: #baedf5;" type="password">
<a href="{url}/api.php">
<button class="login green" name="login" style="height:34px;" type="submit">Let's go!</button>
</a>
<a>
<button class="login red" style="height:34px; margin-left: 4px" type="sumbit">Forgot your password?</button>
</a>
</div>
CSS
pre, blockquote {
border: 1px solid #999;
page-break-inside: avoid
}
thead {
display: table-header-group
}
tr, img {
page-break-inside: avoid
}
img {
max-width: 100%!important
}
#page {
margin: .5cm
}
p, h2, h3 {
orphans: 3;
widows: 3
}
h2, h3 {
page-break-after: avoid
}
}
html {
height: 100%
}
body {
height: 100%;
margin: 0;
padding: 0;
color: #e0eff5;
background-attachment: fixed;
background-color: #013448;
background-image: url('http://localhost/app/tpl/skins/aura/habboweb/planet.png');
background-image: url('http://localhost/app/tpl/skins/aura/habboweb/planet.png'), -webkit-radial-gradient(190px 190px, circle farthest-side, #0297c8 0, #013448 480px);
background-image: url('http://localhost/app/tpl/skins/aura/habboweb/planet.png'), -moz-radial-gradient(190px 190px, circle farthest-side, #0297c8 0, #2D3877 480px);
, -ms-radial-gradient(190px 190px, circle farthest-side, #0297c8 0, #013448 480px);
, radial-gradient(circle farthest-side at 190px 190px, #0297c8 0, #013448 480px);
min-height: 755px
}
i, cite, em, var, address, dfn {
font-style: italic;
}
body {
font-family: "Ubuntu Condensed", Arial, serif;
font-weight: normal;
min-height: 0;
}
#footer a {
color: #a1b5c8;
text-decoration: none;
font-size: 13px;
}
body {
font-size: 1em;
line-height: 1.4;
}
.form__input, .form__select {
box-shadow: inset 0 2px 0 0 #9ebecc;
line-height: 1.2;
padding: 5px 12px;
width: 100%;
font-size: 16px;
}
.button b, .new-button i {
position: absolute;
display: block;
left: 2px;
top: 3px;
right: 2px;
height: 9px;
background-color: #4a9fb4;
z-index: 0
}
.button:hover, .new-button:hover {
background-color: #418491
}
.button:hover b, .new-button:hover i {
background-color: #46a9bf
}
.button span, .new-button b {
position: relative;
z-index: 100
}
.button:active, .button-active, .new-button:active {
left: 1px;
top: 1px;
box-shadow: 2px 2px rgba(0, 0, 0, 0.4)
}
.button.dimmed {
-ms-filter: "alpha(opacity=50)";
filter: alpha(opacity=50);
-moz-opacity: .5;
opacity: .50
}
.button.large {
height: 100px;
background-color: #c78800;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border: 1px solid #5f4416
}
.button.large:hover {
background-color: #d99b00
}
.button.large:hover b {
background-color: #f7ce00
}
.button.large b {
left: 4px;
top: 4px;
right: 4px;
height: 48px;
background-color: #f0bb00;
-webkit-border-radius: 2px 2px 0 0;
-moz-border-radius: 2px 2px 0 0;
border-radius: 2px 2px 0 0
}
.button.large span {
display: block;
font-size: 27px;
font-weight: bold;
text-transform: uppercase;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
line-height: 54px
}
.button.large span.sub {
display: block;
font-size: 17px;
font-weight: bold;
line-height: 42px;
text-transform: none
}
.button.large.not-so-large {
height: 48px
}
.button.large.not-so-large b {
height: 20px
}
.button.large.not-so-large span {
text-transform: none;
font-size: 22px;
line-height: 46px
}
header, footer {
width: 100%;
background: #101016;
background: rgba(16, 16, 22, 0.85);
position: fixed;
z-index: 999
}
#login-errors {
width: 100%;
height: 35px;
background-color: #c00;
color: #fff;
font-size: 17px;
font-weight: bold;
text-align: center;
line-height: 35px
}
#login-errors a {
color: #000
}
#footer-content {
float: left;
margin-left: 50px
}
#footer-content.partner-logo-present {
margin-left: 20px
}
#footer {
width: 100%;
min-width: 780px;
margin-top: 19px
}
header {
top: 0;
min-height: 99px
}
header #border-left {
position: absolute;
width: 500px;
height: 1px;
left: 0;
bottom: 0;
border-bottom: 1px solid #7aa3b9
}
header #border-right {
position: absolute;
width: 100%;
height: 1px;
left: 220px;
bottom: 0;
border-bottom: 1px solid #7aa3b9
}
footer {
height: 69px;
bottom: 0;
border-top: 1px solid #7aa3b9
}
#top-bar-triangle, #top-bar-triangle-border {
position: absolute;
left: 163px;
bottom: -29px
}
#top-bar-triangle {
font-size: 0;
height: 0;
line-height: 0;
border-style: solid;
float: left;
margin: 0;
border-color: #101016 transparent;
border-color: rgba(16, 16, 22, 0.85) transparent;
border-width: 29px 29px 0 29px
}
#top-bar-triangle-border {
background-image: url('http://localhost/images/new_index/images/v3/top_bar_arrow_border.out.png');
width: 58px;
height: 29px
}
header #habbo-logo {
position: absolute;
width: 190px;
height: 52px;
background-image: url('http://localhost/app/tpl/skins/aura/images/logo.png');
left: 32px;
top: 27px
}
#login-form-container {
position: relative
}
header form {
position: relative;
left: 239px;
top: 0;
width: 740px;
height: 99px
}
#login-columns {
position: relative
}
header form.captcha {
height: 200px
}
header form.captcha #login-recaptcha {
height: 103px;
margin-top: 8px
}
#login-recaptcha .field-error, #login-recaptcha #captcha-overlay {
display: none
}
#login-column-1 {
position: absolute;
left: 0;
top: 11px;
width: 205px;
height: 70px
}
#login-column-2 {
position: absolute;
left: 214px;
top: 11px;
width: 134px;
height: 70px
}
#login-column-3 {
position: absolute;
left: 358px;
top: 32px;
width: 205px;
height: 55px
}
Set vertical-align: middle; on the inputs and remove the margin-top from the inline styles in the logo <img> tag.
While I'm at this, though...General cleanup of this code is probably a good idea. I would like to caution you to avoid mixing inline styles and CSS. Also, the <br> tag should probably be replaced with padding - that line break and the inline styles are there only for design purposes and design is handled in CSS. Keeping as much design out of the HTML will help you (or someone else) easily make changes to this site later, if needed. The <img> tag's styles also include two margin-left values. I would remove one to avoid confusion. Lastly, I think you will want to remove <div align=; from the <img> tag's styles. As far as I know, this doesn't accomplish anything.
Hope that helps!
I'd like to achieve something like this:
I've done this so far:
just wondering, how to make a purple area with little arrow button and once user click it, it would invoke something.
Here is the html and css code I have:
<div class="searchy">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value=""/>
</div>
CSS:
.searchy{
height: 60px;
background-color: #555;
color: #FFF;
margin-left: -15px;
margin-right: -15px;
}
.fdSearch{
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
margin-left: -15px;
margin-right: -15px;
height: 40px;
vertical-align: middle;
padding: 20px;
margin-top: 15px;
width: 85%;
}
===================update==========================
Thank you guys....They all works. I just pick up one for the right answer.
I've learnt a lot from codes with different version of answers below. Thank you for your help again.
Fiddle: http://jsfiddle.net/hBdMz/
Css:
.form-wrapper {
width: auto;
padding:4px;
background: #555;
clear:both;
display:table;
}
/* Form text input */
.form-wrapper input {
width: 330px;
height: 20px;
padding: 10px 5px;
float: left;
border: 0;
background: white;
border-radius: 3px 0 0 3px;
outline:none;
}
/* Form submit button */
.form-wrapper button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
color: black;
text-transform: uppercase;
background: #9B30FF;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
}
.form-wrapper button:before {
content: '';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent #9B30FF transparent;
top: 12px;
left: -6px;
}
Html:
<div class="form-wrapper">
<input type="text" placeholder="Search here..." required>
<button type="submit">Search</button>
</div>
Adapted from: speckyboy
Check This Fiddle
HTML
<div class="searchy">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch"
value=""/>
<button type="submit">Submit</button>
</div>
CSS
.searchy {
background: grey;
padding: 50px 20px;
}
input {
border:none;
background: none;
border-top: 3px solid #e1e1e1;
border-left: 3px solid #e1e1e1;
border-bottom: 3px solid #e1e1e1;
padding: 10px 3px;
}
button {
border:none;
background: #4fd577;
padding: 9px 10px;
margin-left: -5px;
border-top: 3px solid #e1e1e1;
border-right: 3px solid #e1e1e1;
border-bottom: 3px solid #e1e1e1;
}
button { position: relative; background: #4fd577; }
button:after { right: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; }
button:after { border-color: rgba(79, 213, 119, 0); border-right-color: #4fd577; border-width: 7px; top: 50%; margin-top: -7px; }
Use this tool to create css arrows :- http://cssarrowplease.com/
Inside your form create a division containing a division with the word SEARCH and an img with a unique class.
Position your out division to absolute, top minus the height of your textbox.
Float your Search division to the right, float, your img to the left.
Asign your search division a width and height.
http://jsfiddle.net/5BwLC/22/
HTML
<div class="searchy">
<div class="searc">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value=""/>
<div class="search-button" onclick="f()">
Search
</div>
</div>
</div>
CSS
.searchy{
min-height: 60px;
background-color: #555;
color: #FFF;
margin-left: -15px;
margin-right: -15px;
overflow:hidden;
}
.fdSearch{
float:left;
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
margin-left: -15px;
margin-right: -15px;
min-height: 40px;
vertical-align: middle;
padding: 20px;
margin-top: 15px;
width: 85%;
}
.searc
{
width:85%;
overflow:hidden;
}
.search-button
{
margin-top:15px;
margin-left:-40px;
min-height:40px;
width:10%;
background-color:purple;
float:left;
padding:20px;
vertical-align: middle;
border-radius: 10px;
border: 5px solid #E5E4E2;
}
Would you like the arrow too?
demo: http://jsfiddle.net/gxXYC/
.searchy{
position:relative;
height: 60px;
width:480px;
background-color: #555;
color: #FFF;
}
.searchy:before, .searchy:after{
position:absolute;
top:0;
}
.searchy:before{
content:"";
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right:10px solid blue;
right:100px;
top:20px;
}
.searchy:after{
content: "search";
color:white;
text-align:center;
width: 96px;
height: 84%;
top: 5px;
font-size: 23px;
line-height: 44px;
background: blue;
right: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.fdSearch{
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
height: 100%;
vertical-align: middle;
padding: 20px;
width: 100%;
float:left;
}
the markup
<div class="searchy">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value=""/>
</div>
if you want to use a submit button the git it an absolute position right width the same dimenssion as :after and an opacity :0;
http://jsfiddle.net/gxXYC/2/
Not sure why I'm adding my answer to the heaps, but here it is:
HTML:
<div class="searchy">
<div class="search-wrap">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value="" />
<button type="submit">Search</button>
</div>
</div>
CSS:
.searchy {
height: 60px;
background-color: #555;
color: #FFF;
position: relative;
padding: 0 6%;
}
.searchy:after {
content:'';
height: 100%;
display: inline-block;
vertical-align: middle;
}
.search-wrap {
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
height: 40px;
vertical-align: middle;
width: 85%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
position: relative;
display: inline-block;
}
.search-wrap > input, .search-wrap > button {
margin: 0;
height: 100%;
border: 0;
}
.search-wrap input[type="search"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
width: 100%;
}
/* Unfortunately these have to be separate: http://css-tricks.com/snippets/css/style-placeholder-text/ */
.search-wrap input[type="search"]::-webkit-input-placeholder {
font-style: italic;
}
.search-wrap input[type="search"]:-moz-placeholder {
/* Firefox 18- */
font-style: italic;
}
.search-wrap input[type="search"]::-moz-placeholder {
/* Firefox 19+ */
font-style: italic;
}
.search-wrap input[type="search"]:-ms-input-placeholder {
font-style: italic;
}
.search-wrap button[type="submit"] {
position: absolute;
top: 0;
bottom: 0;
right: 0;
background: #7c7aa9;
color: #fff;
text-transform: uppercase;
padding: 0 10px;
}
.search-wrap button[type="submit"]:before {
position: absolute;
content:'';
border: 6px solid transparent;
border-right-color: #7c7aa9;
height: 0;
top: 0;
bottom: 0;
margin: auto 0;
left: -10px;
}
There's no one 'right' answer to this. Here's how I would do it:
Make the purple box/arrow a background image of the input.
Put the search text/button in an absolutely positioned DIV positioned above the right side of the input box.