Is there a way to adjust the size of an image in a specific section of bootstrap?

Can anyone assist me with fixing an image in part one of a full-size Bootstrap layout to make it look like picture 2? I have included both my current code and the desired outcome.

Current Code and Desired Outcome

Answer №1

It seems like the solution you're looking for involves using the background-image property and setting background-size: cover.

<html>

<head>

  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no" />

  <style>
    body {
      padding: 50px;
      font-family: sans-serif;
    }

    .container {
      width: 500px;
      height: 200px;
      margin: 0 auto;
      background: black;
      display: inline-flex;
    }

    .food {
      background-image: url('https://live.staticflickr.com/3577/3388519531_d8b154f988.jpg');
      background-size: cover;
      width: 200px;
      margin: 12px;

    }

    .text {
      padding: 12px;
      color: white;

    }
  </style>
</head>

<body>
  <div class="container">
    <div class="food">

    </div>
    <div class="text">
      Hello this is your text
    </div>
  </div>
</body>

</html>

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

In Internet Explorer, HTML elements may not always align seamlessly with other elements on the page

What is causing the alignment issue with the Available Times table, Assessor Notes textbox, and Booking Notes textbox in Internet Explorer, while they appear perfectly aligned in Firefox? Here is my CSS: <style type="text/css" media="screen"> h ...

Moving a DIV below a fixed-positioned element

I have a website with a scrollable div. It works well, but I also need an absolutely positioned div on top of it - and it still needs to scroll smoothly without any hindrance. You can check out a basic JSFiddle demonstration here: http://jsfiddle.net/41ra ...

What is the best way to create a highlighting effect with "onmouseover" in CSS?

protected void MasterCust_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowState == DataControlRowState.Alternate) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#eefef0';"); ...

Tips for integrating Shopify CDN into Bootstrap

Hello everyone, I'm a beginner in web development and recently got a project to create an ecommerce website for a client. The client wants something similar to www.gallerydept.com. However, when I inspected the site, I noticed that it uses Shopify&apo ...

the iframe is not properly displaying the embedded responsive page

The primary webpage incorporates the responsive mobile page created with the JQUERY SUPERSLIDES plugin. The mobile page appears correctly when viewed directly on an iPhone using Safari. However, when it is embedded in an iframe, it does not display as expe ...

Adjust the alignment of text to a precise vertical ratio of the image

Let's say I have this amazing logo with some artistic text in it that cannot be replicated using a downloaded WebFont In the image, the text baseline sits at 68% from the top and 32% from the bottom. Now I want to align text in an HTML document, whi ...

Develop an occurrence that hides one <div> element and generates a fresh <div> element in its place

I am in the process of designing an experiment with a web-based notepad. Currently, I have a textarea element that transfers its content to a hidden div when the HTML page is printed. However, I am facing an issue with the overflow of the textarea element. ...

The battle between "this" in HTML and AngularJS ng-model

We have been working on updating an old ColdFusion application that utilized "this" with a formatting function: <td>$<input type="text" name="txtTaxProration" id="txtTaxProration" value="0.00" alt="Tax Proration" onblur="dollarBlur(this);">< ...

developing a tri-step program to assist the user

Is there a way to create responsive circles with equal width and height, center the horizontal line, and also center the numbers in the middle of the circle? .DCQ_Container { display: flex; flex-direction: column; text-align: center; } .Progress_ ...

The issue of the flex: 1 view not expanding to its full height persists, along with the KeyboardAvoidingView functioning unre

My concern lies with a ScrollView that is not occupying the full remaining height, as shown here. The red-bordered view should extend all the way down, but it fails to adjust properly when the keyboard is visible like in the case of selecting the 5th item ...

Reposition HTML content using regular expressions

My objective is to locate a block of HTML that contains comments and relocate it after the header section. The comment itself remains constant, but the content within the block varies across different pages and needs to be replaced using Dreamweaver' ...

What's the best way to position a lone CTA at the center of the second row on a two-column layout using Elementor?

On my page, I am facing a challenge of adding a second section with a single Call to Action (CTA). The previous section on the same page consists of two CTAs placed side by side with a width set at 50% each. However, now I need to add a third CTA without i ...

Are there any available tools or scripting methods for accommodating various vendor prefixes?

My preference is to use standard CSS rules for different styles that include various vendor prefixes. To test, I would start with the following: border-radius: 5px; box-shadow: 0px 0px 4px 0px #fff; transform: rotate(90deg); For the final version, I woul ...

What steps should be taken to have a Django view.py retrieve specific details of a post, like the primary key?

I am currently working on a Django project where an HTML file displays a list of CSV files that have been uploaded to my Postgresql database. When a user clicks on a specific CSV, a new page is rendered showing basic information about the CSV model such as ...

Receiving RSVP via email after sending out invitations

My dilemma lies in sending an invitation message via email to two individuals, complete with two link buttons offering the options to either Approve or Reject. The question now becomes: How can I track who has clicked on the Approve button? This way, I ca ...

Using Bootstrap columns within a PHP loop

I've been researching various solutions for this issue, but none of them seem to be working with my current code. Right now, my products are being displayed in a single column, but I would like them to be shown in a 3 or 4 column grid layout instead. ...

Tips for storing the output of a script URL in a JavaScript variable

I am currently facing an issue with running a script in the 'head' element of a webpage. The script makes an API call to a specific URL and retrieves results in the form of a JavaScript array. However, I am encountering difficulty because the API ...

What steps should I take to transform this into a :nth-child css selector that is dynamic?

Currently, I am designing a diamond grid system using CSS. I am facing an issue where I need to shift the 5th block to the left and then every 7th subsequent block after that (12th, 19th, 26th, etc). Is there a way to create a dynamic nth selector for th ...

The display:block links are not properly positioned within the absolute div

I'm having trouble figuring out why my links are not working for the .pushMenu divs on the left and right side, html: <header class="header"> <div class="pushMenu" id="left"> <a href="" title=""><p>l</p>< ...

Is MeshFaceMaterial in Three.js causing issues with opacity of cubeMaterials and THREE.DoubleSide functionality?

I am currently utilizing ThreeJS r65 to construct a basic cube. The cube's opposite faces are assigned the same colors: var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000); v ...