Responsive full page image (100% height)

时间:2017-08-30 20:49:11

标签: css height background-image responsive

Although there is a lot of content on this specific topic, I've tried the pointers given by others to no avail.

I have a div with the id=headerimg as can be seen here:-

https://jsfiddle.net/9d3bmpxc/1/

as you can see I have used the common css for a full width responsive image:-

&

As you will see in the JSFiddle link my image is not responsive, Even if I set the min height to 100% nothing happens.

Please also note that the four dots at the top indicate my nav which is not styled.

Your help is much appreciated.

1 个答案:

答案 0 :(得分:1)

If you want to set the height of an element to 100%, you also need to set the height of the parent too (in this case, the body). If you add <div class="container"> <div class="row"> @{ var store = (Site)ViewData["sites"]; var concept = (Concept)Session["concept"]; <div class="row"> <div class="col-sm-6"> <div> <h3>@store.name</h3> <p> @store.address1<br /> @store.city, @store.state @store.zip<br /> @store.phone </p> </div> <div> <h4>Pick Up Time</h4> When do you want to pick up your order? <br /> Soon As Possible @Html.RadioButton("pickUp", @store.getOrderingASAPTime(), new { @checked = "checked" }) (Pick up will be ready at: @store.getOrderingASAPTime().ToShortTimeString()) <br />Select Another time @Html.RadioButton("pickUp", "differentTime") </div> <div class="calender"> <div> <input type="text" id="datepicker" name="date" value="Pick a Date"> </div> <div class="col-sm-1" id="timepick"> <select class="form-control " id="timepicker"> </select> </div> @section scripts { <script> $(function () { $("#datepicker").datepicker({ dateFormat: "DD mm-dd-yy", minDate: 0, autoclose: true, onSelect: function (selected, evnt) { updateAb(selected); } }); }); function updateAb(value) { $.ajax({ type: "POST", url: '@Url.Action("GetTimeOptions", "OrderTime")', contentType: "application/json; charset=utf-8", data: { a: "testing" }, dataType: "json", success: function () { alert('Success'); }, error: function () { alert('Error'); } }); }; </script> } </div> </div> <div class="col-sm-6"><br /> <h4>Store Hours</h4> Monday @store.MonOpen - @store.MonClose <br />Tuesday @store.TueOpen - @store.TueClose <br />Wednesday @store.WedOpen - @store.WedClose <br />Thursday @store.ThuOpen - @store.ThuClose <br />Friday @store.FriOpen - @store.FriClose <br />Saturday @store.SatOpen - @store.SatClose <br />Sunday @store.SunOpen - @store.SunClose </div> </div> <div class="row col-sm-4" style="padding-top: 20px;"> <button class="btn" type="submit" onclick='window.location = "@Url.Action("MenuPage", "MenuPage", new { siteID = @store.seq })";' style="background-color: @concept.PrimaryBackgroundColor; color: @concept.PrimaryForegroundColor;">Place Order</button> <div><a href="@Url.Action("Index", "StoreListing")">Not The Store You Want?</a></div> </div> <script> $(document).ready(function () { $('#datepicker').hide(); $('#timepicker').hide(); $('input[type="radio"]').click(function () { if ($(this).attr('value') == 'differentTime') { $('#datepicker').show(); $('#timepicker').show(); } else { $('#datepicker').hide(); $('#timepicker').hide(); } }); }); </script> } </div> to your #headerimg element and the following to your CSS:

public class OrderTimeController : Controller
{
    // GET: OrderTime
    public ActionResult StoreInfo(int siteID)
    {

        Site result = SiteMgmt.GetSite(siteID);
        var emptyResult = new Site();
        if (siteID == 0)
        {
            View().ViewData["sites"] = emptyResult;
        }
        else
        {
            View().ViewData["sites"] = result;
        }

        return View();
    }

    public ActionResult GetTimeOptions(DateTime pickUpDate)
    {

        Site site = View().ViewData["sites"] as Site;
        DateTime startTime = DateTime.MinValue;
        DateTime endTime = DateTime.MinValue;

        switch (pickUpDate.DayOfWeek)
        {
            case DayOfWeek.Sunday:
                startTime = site.OOSunStart;
                endTime = site.OOSunEnd;
                break;
            case DayOfWeek.Monday:
                startTime = site.OOMonStart;
                endTime = site.OOMonEnd;
                break;
            case DayOfWeek.Tuesday:
                startTime = site.OOTueStart;
                endTime = site.OOTueEnd;
                break;
            case DayOfWeek.Wednesday:
                startTime = site.OOWedStart;
                endTime = site.OOWedEnd;
                break;
            case DayOfWeek.Thursday:
                startTime = site.OOThuStart;
                endTime = site.OOThuEnd;
                break;
            case DayOfWeek.Friday:
                startTime = site.OOFriStart;
                endTime = site.OOFriEnd;
                break;
            case DayOfWeek.Saturday:
                startTime = site.OOSatStart;
                endTime = site.OOSatEnd;
                break;
            default:
                break;
        }

        List<string> results = new List<string>();
        if (pickUpDate.Date == DateTime.Now.Date)
        {
            if (startTime.TimeOfDay < DateTime.Now.TimeOfDay)
            {
                startTime = DateTime.Now.AddMinutes(site.leadTime);
            }
        }

        DateTime tempTime = startTime;

        do
        {
            tempTime = tempTime.AddMinutes(15);
            results.Add(tempTime.TimeOfDay.ToString());
        } while (tempTime <= endTime);


        View().ViewData["availableTimes"] = results;


        return View();
    }
}
}

This should display your image with full height.

相关问题