How to put an image in an HTML button

I am creating a button on a certain page and would like to put a background image.

I'm trying to use the background-image:url() tag in CSS but it's not working.

HTML:

@model WebApplication3.Models.Comercial.ComercialModels

@{
    ViewBag.Title = "Index";
}
<div id="Open_menu">
    <span onclick="openNav()">Menu</span>
</div>

<h2>Comercial</h2>

<div id="mySidenav" class="sidenav">
    <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
    <a href="#">@Html.ActionLink("Home", "Index", "MenuInicial")</a>
    <a href="#">@Html.ActionLink("Serviços", "Index", "Servicos")</a>
    <a href="#">@Html.ActionLink("Comercial", "Index", "Comercial")</a>
    <a href="#">@Html.ActionLink("Estoque", "Index", "Estoque")</a>
    <a href="#">@Html.ActionLink("Equipamentos", "Index", "Equipamentos")</a>
    <a href="#">@Html.ActionLink("Compras", "Index", "Compras")</a>
    <a href="#">@Html.ActionLink("Fiscal", "Index", "Fiscal")</a>
    <a href="#">@Html.ActionLink("Caixa", "Index", "Caixa")</a>
</div>

<div>
    <input type="button" class="but_clientes">
</div>

CSS:

/*botao abrir menu lateral*/

#Open_menu {
    position: fixed;
    cursor:pointer;
    margin-left: -150px;
    margin-top: 350px;
    font-size: 20px;
    transform: rotate(270deg)
}

.but_clientes {
    width: 300px;
    height: 100px;
    background-color: transparent;
    background-image:url('C:\clientes.png');
    border: groove
}

Fabric:

insert the description of the image here

Project hierarchy:

insert the description of the image here

Update, a folder was created in the project called Image but still, it did not work:

insert the description of the image here

Author: Thomas Erich Pimentel, 2016-10-23

2 answers

In the case of a website, files cannot be served from your local system. First, because the system where the site will be hosted will not (certainly) have the same system as yours (may, for example, not exist c:\). Second because, in case you are making an application that you want to only run on your browser in your home, it is a security system in the new browsers.

To be sure, you have to create a folder in your project that will be served by the server, for example Images, and point the images there. ex: background-image:url(Images/image.ext)

If, however, you want the second option and you do not have a server serving the index.html you have to go find which is the flag of the browser you use; make a new shortcut to the browser and in the call parameters include that same flag. In the case of chrome, it is --allow-file-access-from-files.

 1
Author: MoshMage, 2016-11-09 18:27:40

Tries like this:

<input type="image" src="http://www.drpeppersnapplegroup.com/smedia/www/2013/04/17/img-volunteer-button_163957695590.jpg" alt="Submit" width="110" height="40">
 4
Author: MagicHat, 2016-10-23 16:39:11