问题
I'm still fiddling with MVC and I want to set a full background image which would be retrieved from the database.
This is what I used to do in CSS and love to do whenever I need full background:
.banana3-sm{
background-image: url('../images/banana3-sm.png');
background-size: contain;
background-position: center center;
background-repeat: no-repeat;
height: 100%;
}
Below is what I'm using currently because I don't know how to upload the image link from database to CSS.
In Controller:
model.ImgSrc = Convert.ToBase64String(model.Image);
In CSHTML:
<div class="col-lg-6 col-md-6 visible-md visible-lg">
@Html.Partial("_ProductImage", Model)
</div>
In PartialView
<img class="img-responsive" src="@imgSrc" alt="Product Image" />
But the image isn't as responsive as I want it to be in the above <img>
way.
So there a way I could insert the image link into here dynamically?
background-image: url('xx/xx/xxxx.png');
Thanks in advance!
And I have already read these similar threads as well on here:
how-to-apply-full-background-image-in-asp-net-mvc
css-background-image-refuses-to-display-in-asp-net-mvc
来源:https://stackoverflow.com/questions/47009912/asp-mvc-upload-image-from-database-as-full-background-css