Dynamic banner image

I currently have a jumbotron image in the background, but it isn't as responsive and I'm struggling to get the whole image to display properly. Here is what it looks like currently:

https://i.sstatic.net/IpuDi.png

Here is the full image for reference:

https://i.sstatic.net/wdPCQ.jpg

Below is the HTML code for the jumbotron section:

<div class="jumbotron">

    <div class="row">
        <div class="col-md-7 banner">
            <h2><span class="text-red">Lyfe</span></h2>
        </div>
    </div>


    <%= form_tag search_path, method: :get do %>
        <div class="row">
            <div class="col-md-offset-1 col-md-10">
                <%= text_field_tag :search, params[:search], placeholder: " Enter Delivery Address", class: "form-control text-center", id: "autohome" %>
            </div>
        </div>
        <br/><br/>

        <div class="row">
            <div class="col-md-offset-4 col-md-4">
                <%= submit_tag "Search", class: "btn btn-normal btn-block" %>
            </div>
        </div>
    <% end %>
</div>

And here is the corresponding CSS code:

.jumbotron {
  background-image: url(IMG-1373.JPG);
  background-size: cover;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  overflow: hidden;
  width: 130%;
  right: 121px;
}

Answer №1

Since your layout is full width and the image you are using is in portrait mode, the entire image may not be visible. To make sure more of the image is shown, consider using the following code:

.jumbotron {
   background-position: center 20%;
   background-size: cover;
}

If you want to create a full screen jumbotron, you can try this code instead:

.jumbotron {
   height: 100vh;
   background-position: center 20%;
   background-size: cover;
}

This will help ensure that the maximum amount of information from your photo is displayed.

Answer №2

An issue arises because your image is in portrait orientation. You might want to try using background-size: contain; to solve this problem.

Answer №3

To update your jumbotron styling, make the following changes:

.jumbotron {
  background-image: url(IMG-1373.JPG);
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: auto;
  right: 121px;
}

For more information on responsive images, check out this resource to ensure industry standard responsiveness.

Answer №4

To achieve the desired output, consider using the background-size property with a value of 100% for both width and height:

.jumbotron {
  background-image: url(https://i.sstatic.net/wdPCQ.jpg);
  background-size: 100% 100%;
}

.text-red{
  color: tomato;
}

.btn {
  background-color: tomato !important;
  color: white !important;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" type="text/css" />

<div class="jumbotron">
  <div class="row">
    <div class="col-md-7 banner">
      <h2><span class="text-red">Lyfe</span></h2>
    </div>
  </div>
  <div class="row">
    <div class="col-md-offset-1 col-md-10">
      <input type="text" class="form-control text-center" placeholder="Enter Delivery Address">
    </div>
  </div>
  <br/><br/>
  <div class="row">
    <div class="col-sm-offset-4 col-sm-4">
      <button class="form-control btn">Search</button>
    </div>
  </div>
</div>


<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.bundle.min.js"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to enlarge the size of specific letters in HTML

I am looking to enhance the values of C and I. In addition, I am utilizing ::first-text{}. This is currently functioning well. Now, the question arises - how can I elevate the value of I. <p>Creating and Implementing</p> <center> < ...

Manage the placement of elements using CSS

Having an issue here. The blue-colored elements are showing up vertically, but I want them to be displayed horizontally. I've tried various methods but haven't been able to solve the problem. Providing just the code for the items below due to len ...

Adding a new row to a table is causing issues with jQuery

var info = [{ "pin": "015-08-0011-000-01", "arp": "015-08-0011-000-01", "tin": "342-432-423-000", "firstname": "John", "middlename": "James", "lastname": "Jones", "suffix": "", "qtr": "1st ...

Sharing Iframes across various Components within a Single Page Application (like Youtube)

Did you know that Youtube now lets you minimize the player while browsing the site? It's similar to the functionality on LolEsports.com with Twitch and embedded Youtube players. I'm interested in adding this feature to my own website. Here' ...

Using JS regular expressions to only select anchor (a) tags with specific attributes

When trying to select a link tag (a) with a specific data-attr, I encountered an issue. I currently use the following regex pattern: /<a.*?data-extra-url=".*?<\/a>/g. However, I noticed that this selection goes wrong when there are no line br ...

Achieving left text alignment in CSS for an excerpt using the Ultimate Posts Widget on Wordpress

I've been trying to align the text in the excerpt of a widget called "To-Do List" on the left sidebar. I attempted to set the text-align property to left for the excerpt text, targeting the p tag within the .widget_ultimate_posts, .uw posts using CSS ...

jQuery class does not apply correctly in IE9

Currently, I'm designing a menu for a WordPress theme and facing a styling issue. I aim to differentiate between menu items with submenus and those without by applying different styles on hover. Here's the jQuery code snippet I am using: $(docum ...

Press one button to activate another button

I am looking to activate a button's class by clicking on another button. The button I have is: <button class="clear-cart banner-btn">clear cart</button> This button is used for clearing a cart. On the order confirmation page, I click on ...

Ways to Customize <td> Elements Within a <table> Container

Currently, I am utilizing jsp along with css to style the <td> within the <table> tag. My desired code format is shown below: https://i.sstatic.net/WJjA8.png However, what I am currently receiving is: https://i.sstatic.net/bLyvd.png #beng ...

JavaScript has thrown an error stating that the function in my jQuery script is undefined

I encountered an issue Uncaught TypeError: undefined is not a function in my jQuery script. Here is the code snippet: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link re ...

Customizing browser titles for various article pages on Joomla 3.2 for improved SEO performance

Is there a way to incorporate unique browser titles for various article pages? Additionally, I am seeking guidance on how to integrate distinct meta tags for different pages within a Joomla website... ...

Utilize JavaScript/jQuery to check for upcoming deadlines in a SharePoint 2013 list

I need to check if an item is due based on its date. When a user creates an item with a date in the format MM/DD (e.g., 06/15), I want to determine if that date falls within the next 30 days, turning it red, within the next 60 days, turning it orange, or g ...

The click function for the responsive navbar hamburger is not functioning properly

Having some trouble with the code not working in responsive mode. I've tested it on a 600px screen and the hamburger button doesn't seem to work (I click it and nothing happens). I've gone through both the CSS and JS multiple times but can&a ...

Searching for components in Python Selenium - a missing element

Encountered a strange issue with the "find_elements_by_css_selector" function in Selenium. Despite expecting to retrieve 10 elements, only 9 are returned consistently across various page examples. Interestingly, when testing the same selector using JavaScr ...

Struggling with extracting and transferring data from a span tag to another field within the same form using selenium and python

I am struggling with an issue while running a code using selenium in Python. I am trying to extract values from span tags and store them in variables named "cap1, cap2, and cap3." After saving these values, I need to input them into another field on a web ...

embedding an Image onto a webpage without requiring a source

How can I incorporate an image into my HTML page and then send it via fax without using the "src" attribute? Any suggestions on converting the image to a byte array and embedding it in the html document? ...

Changing the Color of a Table Cell with jQuery

I have designed a table cell in the following way <tr> <td id = 'even'>row 8, cell 1</td> <td id = 'odd'>row 8, cell 2</td> </tr> The colors and font sizes are defined using the CSS below #even { ...

Implementing the principles of angular material design as a stand-alone design system separate from the Angular

Is it possible to exclusively use Angular Material as a design framework, similar to how one would use Bootstrap? I am not particularly inclined to use AngularJS at the moment. Do you have any advice or recommendations on this matter? ...

Tips and tricks for implementing vuetify tooltips within a list component

Looking for help with my code: <div id='app'> <v-app> <v-list-tile-content> <v-list-tile v-for="(item, index) in items" :key="item.id" > <v-list-tile-action> {{index+1}}. </v-list-tile-action> < ...

Achieving both vertical and horizontal center alignment specifically for mobile devices

Is there a way to center a column on mobile devices only while maintaining a fixed height for the section? <div class="" style="background-image: url(image url;); background-position: right bottom; background-size: cover; height: 462px;"> <div cl ...