What is the best way to create a responsive two-column layout with drop caps that doesn't require scrollbars?

Currently, I am delving into the fundamentals of HTML and CSS with a goal to construct my own blog entirely from scratch by coding it manually. This hands-on approach is crucial for my learning process as it allows me to grasp the intricacies better. To ensure responsiveness across different screen sizes, I'm utilizing the Bootstrap grid system but opting for custom components rather than the standard ones provided by Bootstrap as they seem somewhat generic.

My main challenge lies in creating a single DIV element at the top of the page to showcase my latest blog post. This DIV contains a floated image along with two columns of text. By structuring everything within rows in the grid layout, my objective is to achieve seamless realignment of text based on varying screen widths without invoking scrollbars. Is there a workaround for achieving this seamlessly?

To provide further context, I've included snippets of the relevant DIV section alongside its CSS styling below. While the positioning at the top poses some difficulties, I believe these can be ironed out or brought up in a separate inquiry if required. Your assistance in resolving these issues is greatly appreciated.

If you need to refer to the full code, it's available towards the end.

Answer №1

Kudos to you for taking on the challenge of coding a project like this from scratch! It's always great to learn by doing.

The reason you're seeing scrollbars is because you've set the height of the div in your #fbPost instead of letting it adjust based on the content. Additionally, setting overflow: auto prompts the browser to display a scrollbar if the content overflows the container, and to hide it if not. You can find more information on this here.

As a general rule, an id should be unique. Therefore, there should only be one element with id="fbPost" in your HTML, rather than multiple sections. Using classes like your ourCard class is advisable for styling multiple elements.

To create a two-column layout, you can simply utilize the column-count CSS property.

I suggest exploring and mastering CSS Grid for layouts instead of relying on floats (unless correctly used for images, as intended). Floats are not recommended for columns or overall layout design.

For a visual representation of these concepts, refer to this basic JSFiddle demonstration: https://jsfiddle.net/karlynelson/vd7zq8h4/29/

You can employ media queries to switch to a single column layout at a specific breakpoint, or explore utilizing advanced CSS grid techniques like min-max and auto-fill for automatic adjustment, as detailed here.

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

Steps to create a hover effect that alters the appearance of another chosen "element"

For instance, I have two classes named A and B. I want to be able to change the appearance of B when I hover over it, such as its color or size. I am unsure if this can be achieved using CSS and the onmouseover event. I am including a snippet of code that ...

Steer clear of altering line spacing in CSS

Here is the HTML structure that I am working with: <div id="id1"> <h1>my name </h1><h3><a href="mailto:myemail_id"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff92869a929e9693969bbf878685d19 ...

Experience the thrill of success with a timed animation using Sweet Alert on the powerful Ionic framework

I'm currently working with the ionic framework to develop a mobile application. I'd like to incorporate Sweet Alert for displaying success messages. You can find Sweet Alert at . My goal is to include a timer in the success message. swal("Good ...

Ways to display or conceal an anchor tag depending on the database value

I am facing an issue with my aspx page where I have a listview containing three tags - one for hotel invoice, the second for package, and the third for vehicle. Currently, all three tags are visible. What I want is for the visibility of the tags to chang ...

Certain Bootstrap 5 icons are failing to appear on the screen

I'm encountering an issue with Bootstrap 5 where certain icons are not displaying correctly. The bi-search icon shows up perfectly, but the bi-send icon is not being shown at all. I would usually include this in a code snippet, but it seems that featu ...

Adding extra spacing in an li element

As a developer, my knowledge of CSS is not extensive. I am currently facing a simple issue while working with Sitefinity CMS. On one of the pages, I have utilized ul and li elements. The designer has provided me with CSS for li that looks like this: .list ...

Utilizing a Bootstrap grid system (or an IE-compatible CSS grid) to align elements on the provided

Looking for suggestions on achieving the following layout without using CSS grid, either with Bootstrap or IE compatible CSS grid. On large screens: Head and body stack on the left, with an image on the right covering the height of both. [&mdash ...

Guide to selecting a specific element in a loaded template depending on an *ngIf statement

I'm having trouble accessing an element in my template using a template variable as it keeps returning as undefined. At a specific route in my application, my component makes a call to fetch some data within the forkJoin method from rxjs. Due to the ...

What causes certain webpages to experience delays? (Advertisement impact)

Whenever I visit low-quality websites filled with ads, I often experience a delay where part of the site loads and then stalls for seconds before loading the rest. However, when I use AdBlock, the site loads much faster. What exactly is causing this stal ...

navigating to the start of a hyperlink

I'm having issues with scrolling to anchors and encountering 3 specific problems: If I hover over two panels and click a link to one of them, nothing happens. When I'm on section D and click on section C, it scrolls to the end of section C. ...

Retrieving the value of the selected radio button

How do I access the value of a clicked radio button? I am trying to create a custom filter based on the gender selected in my <form>. However, when using the filter and orderBy in my ng-repeat, it is not functioning correctly. You can view an examp ...

"Using enchant.js to create a game that utilizes an if statement to show a specific

I am looking to implement an if statement into my game that will display an html div (#game-over) once a certain score is reached. The div is currently set to "display:none". I have created a js fiddle for the game with the code $('#game-over'). ...

Is it possible to adapt Owl Carousel Liquid to function with percentages?

After successfully installing the owl carousel plugin, I noticed that it does not scale with the viewport size. This has been bothering me as I want the carousel to resize along with the items when the viewport becomes smaller. I attempted to set responsiv ...

Automatically adapt the height of a bootstrap button based on the dimensions of other bootstrap buttons

First and foremost, my objective is to centrally align a glyphicon both vertically and horizontally within a button. Despite attempting CSS attributes like position: relative; and position: absolute;, my efforts have been in vain. You can check out the sam ...

Could really use some help with troubleshooting my jQuery UI Todo List - it's just not

I've been working on a new project using jQuery UI to create a "to do list" application. So far, I've managed to get it up and running, but I'm having trouble displaying the tasks correctly in the designated div. Instead of showing up as a b ...

Automatically populating and submitting a form after receiving search results via ajax

I have been struggling with this issue for a few days now and could really use some help from the experts here. I am new to sql, javascript, jquery, ajax, css, and php. Although I studied Computer Science in college 15 years ago, I seem to be missing some ...

Inclusions of embedded Google Docs in iframes

I recently posted a Google Document with some helpful links. To display it on my webpage, I utilized an iframe code. However, whenever someone clicks on one of the links within the document, the iframe is replaced by the target URL of that link. In order ...

Tips for including a wildcard in a MySQL query while using the '=' operator

I am working with pre parameters that determine the input for my query. For one scenario, I need to search for all UUIDs, while in another situation, I only want to look for specific UUID numbers. Instead of splitting this into two separate calls as shown ...

Text alignment and block dimensions

I attempted to organize three buttons within a block. <link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.0.3/tailwind.min.css" rel="stylesheet"/> <div class="grid grid-cols-1 md:grid-cols-3 text-center place-content-center"> ...

The alignment of the submit button is consistently off when placed alongside two input boxes within a table

Completing this task is usually straightforward. I have a sign-in form with an email input, password input, and submit button aligned horizontally. However, after trying various styles and structures for hours, the button appears slightly lower than the in ...