Is there a possibility to change the buttons image to button_pressed.png while the button is pressed and change it back to button_unpressed.png when the button is released again?
EDIT
I have the following HTML:
<header id="toolbar">
<div id="toolbar_back">
<form action="#/">
<input type="image" />
</form>
</div>
<h1 id="toolbar_title">Photo Prints</h1>
</header>
And the following CSS:
#toolbar {
background: #FFFFFF;
height: 60px;
width: 100%;
margin: 0;
padding: 0;
box-shadow: 0px 2px 1px #888888;
display: table;
}
#toolbar_title {
color: black;
font-size: 30px;
text-align: center;
display: table-cell;
vertical-align: middle;
}
#toolbar_back {
padding-left: 10px;
display: table-cell;
vertical-align: middle;
}
#toolbar_back input {
background: url("../img/toolbar/toolbar_back.png");
}
#toolbar_back input:active {
background: url("../img/toolbar/toolbar_back_pressed.png");
}
But with this the result is the following:
I just want the background images to be shown and i want them to be fully shown.
You'd want to make the button a background image:
#button input {
background-image: url("img/button_unpressed.png");
background-size: cover; /* or 'contain' */
background-repeat: no-repeat;
}
#button input:active,
#button input:focus {
background-image: url("img/button_pressed.png");
}
You'll probably also need to remove border and other styles to only show your background image.
Related
I'm currently trying to use HTML together with CSS and my current problem is that I am not able to connect the input beside the arrow button:
I'm here asking how I am able to make the >> button as a "submit" button and that its beside the input?
--------------
| | >>
--------------
body {
padding: 5px 15px 30px 15px;
width: 500px;
height: 250px;
background-image: url('../images/bg2.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
.text-center {
text-align: center;
}
.form-control {
margin: 600;
}
label {
display: block;
}
select,
input {
min-width: 100px;
border: 1px solid #fff;
background: #292942;
color: #fff;
border-radius: 25px;
padding: 5px 10px;
}
.mt10 {
margin-top: 20px;
}
.submit {
background-image: url('../images/arrow.png');
background-repeat: no-repeat;
background-position: center center;
width: 23px;
height: 23px;
margin-left: 350px;
}
<body>
<div class="text-center">
<div class="form-control">
<input type="text" id="discord-id-input" name="discord-id-input" placeholder="Discord ID" class="mt10">
<div id="discord-id-button" type="submit" class="submit">
</div>
</body>
Some simple flexbox properties get things into shape.
Other tips:
Use a button for submit. If you don't want button styling, take it off. Semantic use of elements is critical for consistent, familiar usage and for accessibility.
Whenever you find yourself using huge margins for layout, take a step back. That's not a good approach. Use flexbox or CSS grid to create a structure in which your content resides, and use margin or padding only to crate a bit of space between elements, or between grid containers and content.
Don't put hard widths on the body. That should almost always remain flexible to fit the screen.
body {
padding: 5px 15px 30px 15px;
/* width: 500px; */
height: 250px;
background-image: url('../images/bg2.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
.text-center {
text-align: center;
}
.form-control {
margin: 600; /* invalid value */
display: flex;
align-items: center;
justify-content: center;
}
label {
display: block;
}
select,
input {
min-width: 100px;
border: 1px solid #fff;
background: #292942;
color: #fff;
border-radius: 25px;
padding: 5px 10px;
}
.mt10 {
margin-top: 20px;
}
.submit-btn {
background-image: url('https://via.placeholder.com/30');
background-repeat: no-repeat;
background-position: center center;
width: 23px;
height: 23px;
margin-left: 12px;
/* margin-left: 350px; */
}
<body>
<div class="text-center">
<div class="form-control mt10">
<input type="text" id="discord-id-input" name="discord-id-input" placeholder="Discord ID">
<button id="discord-id-button" type="submit" class="submit-btn" />
</div>
</div>
</body>
You could use flexbox, like so (Notice I changed the submit button to an HTML button):
.form-control {
display: flex;
align-items: center;
gap:10px;
}
input {
min-width: 100px;
border: 1px solid #fff;
background: #292942;
color: #fff;
border-radius: 25px;
padding: 5px 10px;
}
.submit {
background-image: url("https://img.icons8.com/material-two-tone/24/000000/arrow.png");
background-repeat: no-repeat;
background-position: center center;
background-color: transparent;
outline: none;
border: none;
width: 23px;
height: 23px;
}
<div class="form-control">
<input type="text" id="discord-id-input" name="discord-id-input" placeholder="Discord ID">
<button id="discord-id-button" type="submit" class="submit">
</button>
</div>
I'm trying to make an input field with a button and custom sprite image inside of it.
The input should change the border color and show the button with an
icon while hovering. Additionally while hovering both input and
button, the icon should be changed.
Right now the icon changes with input:focus while dismissing the border of the input.
If somebody can guide me in the right direction, it would be greatly appreciated.
Here's what I came up so far:
HTML
<form class="b-editor-item col-3">
<input type="text" placeholder="D" class="b-editor-d-input" />
<button type="button" class="b-editor-button-delete">
<div class="b-editor-icon-trash"></div>
</button>
</form>
SCSS
input[type="text"] {
border: 1px solid transparent;
}
.b-editor {
&-item {
display: flex;
align-items: center;
}
&-button-delete {
border: none;
height: 24px;
width: 24px;
overflow: hidden;
background-color: transparent;
}
&-d-input {
color: black;
background-color: #eaeaea;
border-radius: 6px;
width: 90%;
margin-right: -3.25rem;
height: 2rem;
}
&-icon-trash {
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/1044597/trash.png);
background-repeat: no-repeat;
background-position: -28px 0;
background-size: 300%;
height: 20px;
width: 20px;
padding: 5px 2px;
}
&-d-input:hover + &-button-delete:hover > &-icon-trash,
&-d-input:focus + &-button-delete:hover > &-icon-trash {
background-position: -52px 0;
}
&-d-input + &-button-delete {
display: none;
}
&-d-input:hover + &-button-delete,
&-d-input:focus + &-button-delete,
&-d-input:hover + &-button-delete:hover {
display: block;
}
&-d-input:hover,
&-d-input:hover + &-button-delete:hover {
border: 1px solid #00c8aa !important;
}
}
Try to add these 2 rules:
button.b-editor-button-delete:hover {
display: block;
}
button.b-editor-button-delete:hover .b-editor-icon-trash {
background-position: -52px 0;
}
I made an image-button which is hovering between to pictures.
For some reason there is a frame around the picture when I set it as a in html.
I've tried to change the button to just and then the weird frame disappears but the the pressed down effect on to button doesn't work.
.img {
padding-left: auto;
align-items: center;
width: 200px;
height: 200px;
background: url("src/assets/red2.png")no-repeat;
}
.img:hover {
padding-left: auto;
align-items: center;
width: 200px;
height: 200px;
background: url("src/assets/red1.png") no-repeat;
}
.img:active {
background: url("src/assets/red1.png") no-repeat;
}
.img:focus {
background: url("src/assets/red1.png") no-repeat;
}
.img:target {
background: url("src/assets/red1.png") no-repeat;
}
<td>
<button type=button (click)="" class="img"></button>
</td>
Just add border:0; to get rid of the grey border and outline: none; if you want to get rid of the blue outline.
.img {
padding-left: auto;
align-items: center;
width: 200px;
height: 200px;
background: url("src/assets/redsmiley2.png")no-repeat;
border: 0;
outline: none;
}
.img:hover {
padding-left: auto;
align-items: center;
width: 200px;
height: 200px;
background: url("src/assets/redsmiley1.png") no-repeat;
}
.img:active {
background: url("src/assets/redsmiley1.png") no-repeat;
}
.img:focus {
background: url("src/assets/redsmiley1.png") no-repeat;
}
.img:target {
background: url("src/assets/redsmiley1.png") no-repeat;
}
<td>
<button type=button (click)="" class="img"></button>
</td>
Try adding
.img{
border:0;
}
Also make sure the
<td>
tag is in a table.
As GolezTrol stated, it's just the button default style to add a border.
What I use in these cases is simply
.img {
border: none;
outline: none;
}
This will ensure that the button has no border and also has no outline when active.
I was trying to create a button using CSS. The html code looks like
<div class="content">
<img src="http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png"/ width="20" height="20">
<span class="fon">Google</span>
</div>
And CSS is
.content {
width: 120px;
overflow: hidden;
color: #f5f5f5;
background: #2d3f51;
}
.content img {
margin: 5px;
float: left;
}
.fon{
position:relative;top:5px;
}
I'm getting output as expected, but I wanted to reduce repetitive html code and move them to CSS, so that I just need to write code similar to below code and should show same output :
<span class="mybutton">Google</span>
Here is my JSFiddle
http://jsfiddle.net/WW4N6/678/
html
<p class="mybutton">Google</p>
css
.mybutton {
background: #2d3f51;
color: #f5f5f5;
display: flex;
align-items: center;
height: 30px;
width: 100px;
padding: 0 5px;
}
.mybutton:before {
content: '';
background: url('http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png');
background-size: cover;
width: 20px;
height: 20px;
display: inline-block
}
JSFiddle: http://jsfiddle.net/WW4N6/681/
css
.mybutton {
width: 90px;
height: 30px;
overflow: hidden;
color: #f5f5f5;
background: #2d3f51;
background-image: url(http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png);
background-size: 20px, 20px;
background-repeat: no-repeat;
background-position: 5px;
padding-top: 10px;
padding-left: 30px;
}
jsFiddle link
http://jsfiddle.net/joshchurning/9sysby5f/
you could use css's background property for your button:
.mybutton {
....
background: url('http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png') no-repeat center center #2d3f51
....
}
If you want to get rid of the HTML code (the width and length of img, I'm assuming), you could just put the width and height in your .content img CSS class
.content img {
margin: 5px;
float: left;
width: 20px;
height: 20px;
}
Im im trying to create custom checkboxes in GWT using only CSS
So far i was able to style checkboxes that DO NOT have text near them.
However checkboxes with text are looking messy
Current state:
Desired behaviour:
<span class="gwt-CheckBox" id="i294">
<input tabindex="0" id="gwt-uid-3" type="checkbox" value="on">
<label for="gwt-uid-3">Run task immediately after finish</label>
</span>
HTML
input[type="checkbox"] {
visibility: hidden;
}
input[type="checkbox"]+label {
display: inline-block;
width: 16px;
height: 16px;
background: url(images/custom_html_elements_sprite.png) 0 0;
}
input[type="checkbox"]:checked+label {
display: inline-block;
width: 16px;
height: 16px;
background: url(images/custom_html_elements_sprite.png) -64px 0;
}
CSS
Any help would be appreciated
EDIT:
fiddle provided
https://jsfiddle.net/2j0zke2z/
It solves all problems: (you can set higher padding if you want)
input[type="checkbox"] {
visibility: hidden;
}
input[type="checkbox"]+label {
display: inline;
width: 16px;
height: 16px;
padding:0 0 0 16px;
background: url(https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/ok_16x16.gif);
background-repeat: no-repeat;
}
input[type="checkbox"]:checked+label {
display: inline;
width: 16px;
height: 16px;
padding:0 0 0 16px;
background: url(http://orig03.deviantart.net/9b11/f/2008/101/c/5/war_skull_16x16__by_xicidal.gif);
background-repeat: no-repeat;
}
This is what you are looking for, just change images, cus I took some by default:
span {
margin-right: 10px;
}
input[type="checkbox"] +
label span {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAMAAAAOARRQAAAAUVBMVEX///8zMzMwMDBEREQqKiotLS3s7OwnJydcXFxJSUkkJCRDQ0P19fVhYWGZmZnd3d1VVVWvr684ODjFxcWKiopvb2+7u7t1dXX5+flpaWnW1ta78F6SAAABiElEQVRoge2ay5aDIBBEG3kp+EDxmf//0JkMYJwzZpERe9W1Mwtuym6OiyqAg2rlx8lZdlHWTaNXNZxLzctghCyuUhgrpDDDMqszyjxJkQGxo4Sc5j+QdRtkPkaQHLb1N+XBdUYnSYXmjyPFV9mtBMnKH7xU4vgfLutwmKh2PyvfvUihDbP8kiwzWrxO5Gk+m04/sabt3qz7R+rahiWQ3uImD9GlcP27O/Wx6t7FQRTDz16rKXJ1mcVJUlfGlySn5z2dI0WUp7f2/1Jl9CO/7dRLeJAuq5enOhcciKUGlSbT56YA9Gk6CrwJZpps03+pboId42EM70y0+SkAbTx8hLhnOvtknup03DVwYTTmDgpAmEjhIHwrC3YPhgUTFuIy2HswNq5xwvB7MJwwhCEMYQhDGMIQhjCEIQxhCEMYwhCGMIQhDGEIQxjCEAYPc3ewghQTIYVeSBEeUiCJFK8ihcVI0TdSkI9VS0AqWWBVRrAKMEh1HqxyElbVCqs4Bkg1OMAq9cGdFcUvpGkd5VrzEsoAAAAASUVORK5CYII=');
background-size: 20px;
height: 17px;
width: 17px;
display: inline-block;
vertical-align: middle;
margin-top: -5px;
}
input[type="checkbox"]:checked + label span {
background: transparent;
}
input[type="checkbox"]:checked + label span::before {
content: "";
background-image: url('https://cdn4.iconfinder.com/data/icons/customicondesignoffice2/128/success.png');
background-size: 20px;
height: 17px;
width: 17px;
display: inline-block;
}
input[type="checkbox"] {
display: none;
}
<input tabindex="0" id="gwt-uid-3" type="checkbox" value="on">
<label for="gwt-uid-3"><span></span>Run task immediately after finish</label>
CSS :
input[type="checkbox"]+label {
display: inline-block;
width: auto;
height: 16px;
background: url(images/custom_html_elements_sprite.png) 0 0;
}
input[type="checkbox"]:checked+label {
display: inline-block;
width: auto;
height: 16px;
background: url(images/custom_html_elements_sprite.png) -64px 0;
}
Does you really want width of 16px only, If you keep it auto it will solve your problem.
Please check this fiddle Link provided here.
Text has been wrapped due to specified width.
Just remove the width and add padding-left as necessary. Also include no-repeat to your background image. Updated fiddle
Note: You can resize the background image using background-size
Snippet
input[type="checkbox"] {
visibility: hidden;
}
input[type="checkbox"]+label {
cursor: pointer;
padding-left: 20px;
display: inline-block;
height: 16px;
background: url(https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/ok_16x16.gif) no-repeat;
}
input[type="checkbox"]:checked+label {
padding-left: 20px;
display: inline-block;
height: 16px;
/* background: transparent; */
background: url(http://orig03.deviantart.net/9b11/f/2008/101/c/5/war_skull_16x16__by_xicidal.gif) no-repeat;
}
<span class="gwt-CheckBox" id="i294">
<input tabindex="0" id="gwt-uid-3" type="checkbox" value="on">
<label for="gwt-uid-3">Run task immediately after finish</label>
</span>
Add Padding-left:20px to your label and remove the width and height form label. Also include no-repeat to your background image.
input[type="checkbox"]+label {
display: inline-block;
background: url(images/custom_html_elements_sprite.png) 0 0 no-repeat;
padding-left:20px;
}
input[type="checkbox"]:checked+label {
display: inline-block;
background: url(images/custom_html_elements_sprite.png) -64px 0 no-repeat;
}
Updated fiddle : https://jsfiddle.net/2j0zke2z/2/
Edited :
is this you want?
input[type="checkbox"] {
visibility: hidden;
}
input[type="checkbox"]+label {
display: inline-block;
background: url(https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/ok_16x16.gif) 0 0;
background-repeat:no-repeat;
padding-left:25px;
}
input[type="checkbox"]:checked+label {
display: inline-block;
background: url(http://orig03.deviantart.net/9b11/f/2008/101/c/5/war_skull_16x16__by_xicidal.gif) 0px 0px;
background-repeat:no-repeat;
padding-left:25px;
}
<span class="gwt-CheckBox" id="i294">
<input tabindex="0" id="gwt-uid-3" type="checkbox" value="on">
<label for="gwt-uid-3">Run task immediately after finish</label>
</span>