Tips for aligning text beneath a CSS-created box

Lately, I've been diving into coding to expand my knowledge of HTML and CSS. So far, I haven't delved into JavaScript just yet.

Currently, I've encountered a challenge. While trying to replicate a PSD file layout into HTML, I need to create a grey box with a subheading and paragraph positioned right in the middle below it. See the image below for reference.

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

.boxes{ 
  width: 500px; 
       background-color: #e6e6e6; 
    display: block;
    height: 130px;
    width: 230px;
    color: white;
    text-align: center;
    padding: .10em; 
    margin: 2em;
    border: double #fff 20px; 
    border-bottom: none; 
} 

.non-icons { 
    margin: 15%;   
}

.box_text{ 
 color: #8c8b8b;

} 
<div class="container"> 
    <div class="four columns">
        <div class="boxes"> 
            <i class="fa fa-desktop fa-4x non-icons"></i> 
        </div>
     <h4 class="box_text"> Web Design</h4>
    </div>
    <div class="four columns">
        <div class="boxes"> 
            <i class="fa fa-shopping-basket fa-4x non-icons"></i>
        </div>
    </div>
    <div class="four columns">
        <div class="boxes"> 
            <i class="fa fa-signal fa-4x non-icons"></i>
        </div>
    </div>   
</div> <!-- End of Container --> 

While everything appears okay in standard view, the layout breaks when the screen size is reduced.

Can someone offer assistance with this issue?

Thank you, Devansh

Answer №1

If you're looking to create a layout that adjusts smoothly across various screen sizes, what you need is a grid. Bootstrap was specifically developed for crafting grids with responsive capabilities.

To get a better understanding, check out this helpful pricing container example from w3schools:

http://www.w3schools.com/bootstrap/bootstrap_theme_company.asp#myCarousel2

You may also want to delve into the workings of the grid system by referring to this detailed explanation:

http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

Answer №2

Utilizing grids is an effective way to create responsive layouts. Consider using percentages (%) instead of fixed units like pixels or ems to achieve a more flexible design.

The grid system in Bootstrap is reliable and easy to use.

If you're looking for another option, Flexbox is a great alternative. Check out this resource for more information: http://www.w3schools.com/css/css3_flexbox.asp

It's worth noting that having two width properties for .boxes can lead to confusion.

Answer №3

If you're not familiar with bootstrap, there's a workaround that might work:

div{
    width:30%;
    overflow:hidden;
    height:250px;
    display:inline-block;
}

You can then place elements inside the divs to make them line up. Feel free to adjust the width and height as needed. Just ensure that the images are the same size/zoom and have consistent padding/margin for a uniform look.

Additionally, it might be worth exploring why some believe PSD to HTML conversion is becoming less prevalent.

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

First-character styling not applying to ID in CSS

My CSS :first-letter selector is effective on all p elements, however when applied to a span with the id #fletter, it doesn't seem to work... #fletter span:first-letter { font-weight: 600; font-size: 25px; } <span id="fletter"> The : ...

Issues with Twitter Bootstrap Rendering in Internet Explorer

Encountering significant challenges in making a Twitter Bootstrap site compatible with Internet Explorer. Visit for the site in question. Below are screenshots from Chrome and Internet Explorer along with the corresponding HTML code. The issue is with the ...

Update the Bootstrap carousel data-interval to stop on the click event of a specific component

I recently implemented a bootstrap carousel on my website featuring one video and two images in the slides. A specific client request was to have the carousel auto slide for 3000ms, but stop sliding when the play button on the video is clicked. I attempted ...

How can I simultaneously submit both the file and form data from two separate forms on a single page using PHP?

My webpage features a form with a series of questions, each followed by an option to upload files if available. I made sure not to nest forms within each other, instead using a method where the upload form pops up separately. However, I encountered an issu ...

Looping through jQuery click() function

I used a loop to generate div elements and I am trying to modify the background-color when the div is clicked. var c = $("#container")[0]; for(var i=0; i<6; i++){ var x = document.createElement("div"); x.className = "sqare"; x.click(changecolor(t ...

What is the method for viewing a PDF file on ng-click without automatically downloading it in AngularJS?

When the user clicks on the link that says "Click to get your file", I am able to download the file. However, now I want to open the PDF file in a modal window and prevent the user from downloading it. This is My Controller: var resumeJson = { "j ...

Ensure that the div remains within the viewport

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Tit ...

What is the best way to eliminate the blank space between div elements on a webpage?

I'm currently working on enhancing my portfolio website, and I'm struggling to eliminate the excessive white space. After inspecting the element, it appears that there is styling related to ul.AMSI, but it's not referenced anywhere in my st ...

Clearly define where each navigation bar item should be displayed within your Django application using Bootstrap

I've been attempting to specify the exact page where this navbar dropdown should be displayed. I attempted adding this line: {% if request.resolver_match.url_name == 'club_selection' %} class = "active" {% endif %} but it doesn&ap ...

Obtaining a document through an Anchor Element

I am currently implementing a feature to allow users to download a zip file using an anchor tag. Here's how it's set up: <a href="download/sample.zip">sample.zip</a> When the file exists in the download directory, everything works s ...

The Ultimate Guide to Mastering Boostrap 4 Layout

I'm struggling to figure this out, but I need the following image: https://i.sstatic.net/F1bIc.png The issue is that the text on the left ("100% digital application process") needs to be within a container to match the margins and padding of the sit ...

An inclusive CSS-compatible calendar control for ASP.NET

I am currently using the Calendar control provided by .NET but I have encountered issues with how it renders HTML in certain situations. Unfortunately, this is hard-coded and cannot be changed. It seems that the Calendar control has not been updated in .NE ...

Does the height of the rendered font adjust based on the length of words in Japanese formatting?

I can't figure out why this strange issue is occurring... It seems that the font "size" (or rather, the height it occupies) changes depending on the length of a word. I tried to reproduce this in English without success, but it consistently happens w ...

Separating a string based on defined separators and substituting certain segments

With content similar to Go to {#www.google.com##Google#}, I aim to transform it into a clickable link, such as: Go to <a href="www.google.com" title="Google">Google</a>. Here is my attempt: var splCharData = splCharData.split(/[\{#\ ...

Adjust the source of the HTML5 video tag based on the orientation of an iPad

I am currently coding an HTML5 page specifically for iPad Mobile Safari, which includes a video tag for embedding video files. I have successfully implemented CSS3 media queries to determine the orientation of the iPad. My next challenge is to dynamically ...

Optimal approach for customizing the appearance of child components based on the parent component

I'm curious about the optimal method for styling child components based on their parent component. For instance, I want to design a list component that can be utilized in both a dropdown popup and a toolbar, each with its own unique style. There are ...

Dynamic content moves unpredictably when adding or modifying TextBoxes or DropDownList items

Whenever I navigate from one textBox to another in my .aspx form, it starts jumping around. The problem is exacerbated when I switch focus to or from a DropDownList. I only have a few textboxes on the form and nothing complex like gridviews or labels. So ...

Display a specific message in a div when the input field is left empty

My goal is to create a div that mirrors the content of an input field. When I type "lalala" in the input, it should show up in the div, and this part is working fine. However, I also want the div to display "The input is empty" when the input itself is emp ...

Guide on how to show an icon in Meteor when a link is clicked

Is there a way to display a viewed icon upon clicking a link in Meteor? On my list of jobs page, when a user clicks on a job, they are taken to the description page. I would like to add an icon to the post indicating that the user has viewed it. ...

Adjust the dimensions of an SVG using a dynamic animation

I have a svg image embedded in this object: <object id="firstrule" type="image/svg+xml" data="/assets/rules/pertinance.svg"></object> I am looking to create an animation that will make the svg image visible on scroll. I have successfully set ...