Adding image to input type submit


Adding image to input type submit



I have a button with an SVG image. I have successfully added the image for div's, but unsure on how to apply it to input tags.


div



For example:




.formLink {
text-align: center;
display: inline-block;
margin: 0 0 88px;
transition: all .25s ease;
max-width: 100%;
box-sizing: border-box;
background: linear-gradient(to right, #e82171, #ef3e36);
padding: 24px 40px;
border-radius: 100px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
font-size: 18px;
color: #fff;
text-decoration: none;
font-family: 'GeomanistRegular', sans-serif;
cursor: pointer;
font-weight: 900;
line-height: 1em;
margin-right: 0;
margin-left: 0;
transition: all .6s;
}

i.arrow {
background: no-repeat;
background-image: url(https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/Arrow.svg);
padding: 7px;
margin: 4px 0 4px 10px;
float: right;
transition: all 0.2s;
}


/***********/

input {
text-align: center;
display: inline-block;
margin: 28px 0 1em;
transition: all .25s ease;
max-width: 100%;
box-sizing: border-box;
padding: 24px 1.2em;
width: 220px;
border-radius: 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
font-size: 18px;
color: #fff;
text-decoration: none;
font-family: 'GeomanistRegular', sans-serif;
cursor: pointer;
font-weight: 900;
line-height: 1em;
background: linear-gradient(to right, #e82171, #ef3e36);
border: 0;
transition: all .6s;
/*background: url(https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/Arrow.svg) no-repeat scroll 14px 7px;
background-size: 20px;*/
}


<br>
<input type="submit" value="Send Message" class="hs-button primary large" data-reactid=".hbspt-forms-0.4.1.0">



As you can see, I've tried to add background:url to the input, but it hide's my whole button?


background:url



I essentially want the send message button to look like the download now button.



Ideas? I cannot change the input HTML. Need to do this through CSS





Are you looking for input type image? developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/image
– rypskar
Jun 29 at 8:59





make it as a button with an action triggered on click? OR wrap in <a> tags
– ThisGuyHasTwoThumbs
Jun 29 at 8:59



<a>





Sorry guys, forgot the clarify, I cannot change the input HTML. Need to do this through CSS.
– Freddy
Jun 29 at 9:03





I opened the image and saw it(cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/…). Its nothing other than plain white background. If you really have some image with picture, you can give background-size: 100%
– Akash Pinnaka
Jun 29 at 9:04



background-size: 100%




2 Answers
2



Here is a Working Example http://jsfiddle.net/xpvt214o/328055/


<br>
<button type="submit" value="Send Message" class="hs-button primary large formLink" data-reactid=".hbspt-forms-0.4.1.0"> Send Message<i class="arrow"></i></button>





test it and up vote please
– Joseph Stalin
Jun 29 at 9:16





This works, but please also add a little detail about why in OP's original HTML code it didn't work.
– Deepak Kamat
Jun 29 at 9:18





we can't put images over input button directly, we have to use either with a <button> || anchor <a> tag || <span> tag with some CSS
– Joseph Stalin
Jun 29 at 9:23





Hi Joseph, I can see it works, but unfortunately I cannot alter the HTML markup. Therefore I cannot change input into a button. Any way to do this via CSS for input?
– Freddy
Jun 29 at 9:58




.formLink {
text-align: center;
display: inline-block;
margin: 0 0 88px;
transition: all .25s ease;
max-width: 100%;
box-sizing: border-box;
background: linear-gradient(to right, #e82171, #ef3e36);
padding: 24px 40px;
border-radius: 100px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
font-size: 18px;
color: #fff;
text-decoration: none;
font-family: 'GeomanistRegular', sans-serif;
cursor: pointer;
font-weight: 900;
line-height: 1em;
margin-right: 0;
margin-left: 0;
transition: all .6s;
}

i.arrow {
background: no-repeat;
background-image: url(https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/Arrow.svg);
padding: 7px;
margin: 4px 0 4px 10px;
float: right;
transition: all 0.2s;
}


/***********/
i.new {
float: left;
position: relative;
background: no-repeat;
background-image: url(https://cdn2.hubspot.net/hubfs/548247/Tomorrow%20People/Landing%20Page/Template%20Build/Arrow.svg);
padding: 7px;
margin: 53px 15px 19px 179px;
transition: all 0.2s;

}

input.hs-button.primary.large.formLink {
position: absolute;
text-align: center;
display: inline-block;
margin: 25px 0 1em;
transition: all .25s ease;
max-width: 100%;
box-sizing: border-box;
padding: 24px 40px;
width: 220px;
border-radius: 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
font-size: 18px;
color: #fff;
text-decoration: none;
font-family: 'GeomanistRegular', sans-serif;
cursor: pointer;
font-weight: 900;
line-height: 1em;
background: linear-gradient(to right, #e82171, #ef3e36);
border: 0;
transition: all .6s;
}


<br>
<input type="submit" value="Send Message" class="hs-button primary large formLink" data-reactid=".hbspt-forms-0.4.1.0"><i class="new"></i></input>






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV