Inline display malfunctioning for text-containing divs

When creating a style sheet for mobile devices, I encountered an issue where the text was displayed in two columns instead of one column like on desktop.

I'm questioning whether the positioning applied to the divs is causing this problem.

Please refer to this fiddle http://jsfiddle.net/vtdo8vc0/

#col1 {
  position: relative;
  display: inline;
  float: left;
  width: 94%;
  padding-right: 3%;
  padding-left: 3%;
}
#col2 {
  position: relative;
  display: inline;
  float: left;
  width: 94%;
  padding-right: 3%;
  padding-left: 3%;
}
.col {
  font-family: 'Avenir-Book';
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}
#main_content {
  padding-left: 10px;
  padding-right: 10px;
  padding-bottom: 10px;
}
#main_content img {
  width: 100%;
  height: auto;
  padding-bottom: 30px;
}
#header {
  position: relative;
  padding-top: 3%;
  padding-left: 3%;
  padding-right: 3%;
  padding-bottom: 3%;
}
.header {
  font-family: 'Avenir-Book';
  font-size: 26px;
  line-height: 26px;
  text-transform: uppercase;
  font-weight: 900;
}
<div id="container">
  <div id="header">
    <div class="header">
      food
    </div>
  </div>
  <div id="col1">
    <div class="col">
      At Danny’s we believe food is very important! Kevin our Head Chef has a wealth of experience and a passion to rival that experience. Wherever possible our food is created using the very best locally sourced ingredients. Whether you are
    </div>
  </div>
  <div id="col2">
    <div class="col">
      popping in for a lunchtime wrap or a full blown Danny's Burger you can expect the same level of service and attention to detail.
      <br>
      <br>Check out our menu below.
    </div>
  </div>
  <div id="main_content">
    <img src="http://placehold.it/350x150" />
  </div>
</div>

Answer №1

It seems like you're looking to make the two columns act as a single block of text on smaller screens. To achieve this, you can set #col1, #col2, and .col elements to display inline and remove the floats from them.

#col1,
#col2 {
  position: relative;
  display: inline;
}
.col {
  display: inline;
  font: 500 12px/16px 'Avenir-Book', sans-serif;
}
#main_content {
  padding: 0 10px 10px 10px;
}
#main_content img {
  width: 100%;
  height: auto;
  padding-bottom: 30px;
}
#header {
  position: relative;
  padding: 3%;
}
.header {
  font: 900 26px/26px 'Avenir-Book', sans-serif;
  text-transform: uppercase;
}
@media all and (min-width: 50em) {
  /* switch to 2 columns on larger screens */
  #col1,
  #col2 {
    display: block;
    float: left;
    width: 47%;
    padding: 0 3%;
    box-sizing: border-box;
  }
}
<div id="container">
  <div id="header">
    <div class="header">
      food
    </div>
  </div>
  <div id="col1">
    <div class="col">
      At Danny’s we believe food is very important! Kevin our Head Chef has a wealth of experience and a passion to rival that experience. Wherever possible our food is created using the very best locally sourced ingredients. Whether you are
    </div>
  </div>
  <div id="col2">
    <div class="col">
      popping in for a lunchtime wrap or a full blown Danny's Burger you can expect the same level of service and attention to detail.
      <br>
      <br>Check out our menu below.
    </div>
  </div>
  <div id="main_content">
    <img src="http://placehold.it/350x150" />
  </div>
</div>

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

What is the best way to transfer table values to a modal in Django?

I am looking to transfer all the values from the specific row to the modal when the edit option is selected in the project. How can I achieve this? Here is the table body code: <tbody class="list form-check-all"> ...

Using AJAX to dynamically load an image by setting the image path as the source of the image tag

I'm facing a challenge with my AJAX call that is used to display user details in a modal. I recently integrated an image upload feature for users, but now I'm struggling to display the uploaded image. I have tried looking for solutions online, bu ...

ColdFusion encounters an HTML form error, presenting the message: "There is an undefined element in the FORM."

I'm attempting to submit an HTML form that contains checkboxes for each day of the week. Whenever a checkbox is checked, I assign a value of 1 to it. To handle unchecked checkboxes, I set a default value of 0 using a CFPARAM tag in the form action pag ...

Central Player Component

Do you need help with centering text and a player on your WP site? Check out my website Here is the code I am currently using: <div class="listen_section"> <div class="container"> <div class="row"> <div class ...

Deactivate the button once the form has been submitted

Seems like a simple and common question, right? I also thought so. How can I achieve this in angularJS? CSHTML @using (Html.BeginForm("Order", "Shop", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) { <div class="container" ng-ap ...

jQuery checkbox toggles multiple divs instead of targeting specific ones

I have set up my page to display divs containing posts using a specific format. The divs are structured as follows (replacing # with the postID from my database): <div id="post_#> <div id="post_#_inside"> <div id="like_#"> ...

Modify a quartet of divs simultaneously

I am currently working on a project that involves 4 input fields, each accompanied by a dropdown element for selecting currency. My goal is to create a JavaScript function that will update all input fields when one of them is changed. For instance, if I s ...

What are the steps to get an Icon to intersect with a v-app-component in a Vuetify project?

The locket is not overlapping with the v-app-bar. How do I make sure they intersect? <template> <v-app-bar :elevation="2" rounded> <v-row class="z-index"> <v-col cols="12" class="d-flex flex-column justify-center align ...

Looking to export a high-quality topographic image?

Is there a way to export the topographical map from this website in high resolution? The map on Google Maps is lacking in detail and important information. The topographical map of Svalbard on the website mentioned is truly impressive, but unfortunately ...

Displaying live data from a spreadsheet directly on a sidebar

My goal is to extract data from another sheet in the same spreadsheet and present it as a dropdown selection in the sidebar. The code.gs file contains a function called getVisualData() that successfully retrieves the desired list: function getVisualData() ...

"Experiencing a callstack overflow due to multiple carousels on one page using Jquery or Vanilla

Currently, I am working on implementing a Jquery infinite autoplay multiple carousel. What I have done is created two separate carousel blocks on the same page within the body section. <div class="rotating_block"> <div class="bl ...

The new data is not being fetched before *ngFor is updating

In the process of developing a "Meeting List" feature that allows users to create new meetings and join existing ones. My technology stack includes: FrontEnd: Angular API: Firebase Cloud Functions DB: Firebase realtime DB To display the list of meeting ...

Browse through all products with just one click using JQuery!

I am trying to achieve a feature where clicking a 'View all' button under the product sheets will display all the products in alphabetical order by adding clones at the bottom of the page to fill all available spaces. Can you assist me with this? ...

Choose the immediate sibling located right after a specific element

My goal is to have the second paragraph following a h1 element display a dropcap, with the first being reserved for the author and date. Although I've tried using different CSS combinations like h1 + p::first-letter {}, it only affects the first para ...

Using the .each() method in jQuery to dynamically assign an attribute to a parent element in JavaScript

I'm new to JavaScript and jQuery and I need help transitioning my code from jQuery to pure JS. Within my HTML, there are multiple parent divs each containing a child div. My goal is to assign a class to both the child and parent elements, with the p ...

Exploring the integration of PostgreSQL into JavaScript

As a beginner in JavaScript, I am looking to create a web page that can store data in a database. Can anyone provide guidance on what resources or materials I should study to learn more about this process? ...

Alternate Row Colors Using Odd/Even CSS Styling for Main Headings

In my expand/collapse table, I have set up alternating row colors (dark grey and light grey) that adjust automatically when expanding or collapsing. The challenge I'm facing is that for certain rows, I want to apply a specific background color using ...

A unique approach to handling ngdisabled for fields that are required only

Starting off with a requirement to disable the submit button when a required field is left empty. <form name="form"> <input type="text" placeholder="First Name" data-ng-model="model.firstName" name="FirstName" ng-required="true" /><br/> ...

Creating full-width divs using BootstrapLearn how to easily create full-width div

Bootstrap is being utilized in my current project. I have been creating divs inside columns, but they are not extending to the full width of the columns. Below is a snippet of the code: <!DOCTYPE html> <html lang="en"> <head> ...

A step-by-step guide on splitting an element into two separate elements using jquery

I have the following code snippet: <h4>user (role) on 26 Nov 2018 20:39:42 +00:00:</h4> My goal is to transform it into this structure: <h4>user (role)</h4> <p>on 26 Nov 2018 20:39:42 +00:00:</p> The <h4> eleme ...