How to add background image for input type=button?
You need to type it without the word image
.
background: url('/image/btn.png') no-repeat;
Tested both ways and this one works.
Example:
<html>
<head>
<style type="text/css">
.button{
background: url(/image/btn.png) no-repeat;
cursor:pointer;
border: none;
}
</style>
</head>
<body>
<input type="button" name="button" value="Search" onclick="showUser()" class="button"/>
<input type="image" name="button" value="Search" onclick="showUser()" class="button"/>
<input type="submit" name="button" value="Search" onclick="showUser()" class="button"/>
</body>
</html>
button background image
Astonishing that no answer addresses or mentions the actual problem here.
The CSS selector button #rock
says "give me an element with the id rock
inside a <button>
element", like this:
<button>
<span id="rock">This element is going to be affected.</span>
</button>
But what you wanted is a <button>
element with the id rock
. And the selector for that would be button#rock
(note the missing space between button and #rock).
And as @Greg already mentioned: #rock
is already specific enough to target the button and could be used on its own.
Can't get a buttons background image to display
Issue was that images, unless explicity imported as:
import D20 from './Images/D20.png';
and then used as:
background: url(${D20});
...will be minified and have their URL changed thanks to webpack.
Found answer here:
https://stackoverflow.com/a/56404570/2796017
how to set a background image of a button to nothing
You want the whole image to be nil rather than passing nil to the UIImage initializer. Try this:
BTN.setImage(nil, for: .selected)
is there anyway to change background image (not color) of button from xml in android studio 4.2.2?
Try this code
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/btn_background"
android:text="@string/ok"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_cancel"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent="0.3"/>
Related Topics
Why Are Horizontal Scroll Bars Shown on My Website
How to Change The Default Message of The Required Field in The Popover of Form-Control in Bootstrap
How to Restrict My Input Type="File" to Accept Only Png Image Files Not Working in Firefox
How to Force Horizontal Scrolling in an HTML List Using CSS
How to Construct a Table Header Than Spans Multiple Rows in HTML
Create Download Link for Music or Video
Website Response Time: Difference Between 'Load' and 'Finish'
After Pseudo Element Not Appearing in Code
Export HTML Content to PDF Using Jasperreports
Jquery Datepicker Won't Work on a Ajax Added HTML Element
How to Center The Twitter Bootstrap Tabs on The Page
How to Render Svg Elements with Crisp Edges While Still Keeping Anti-Aliasing
What Is Difference Between <Pre> and <Code> HTML Tag