Using External CSS: What's the best way to incorporate a class from an external style sheet?

I am struggling to understand how to implement this particular class from my external stylesheet:

.row.rectanglebox {
    margin-top:30px;
    margin-bottom:30px;
    height: 210px;
    border: solid black;
    padding: 20px;
}

Even after attempting the following syntax (which usually works for me), I can't seem to get it right:

<div class="rectanglebox">
       <p> sample text </p>
<div>

The goal is to create a layout similar to the image shown here:

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

Answer №1

The problem lies in the CSS file where .row.rectangle is used to target elements with both the .row and .rectanglebox classes. This means that any element containing the .row class along with the .rectanglebox class or any child of an element with the .row class having the .rectanglebox class will have these styles applied to it.

To resolve this, you can either adjust your code to use class="row rectangleclass" or simplify your CSS by just using .rectangleclass { ... }

Answer №2

It appears that you have forgotten to include the .row class in your div. Here is what you should do:

HTML:

<div class="row rectanglebox">
    <p> sample text </p>
<div>

Just a quick note, when you see .row.rectanglebox, it means that the element has both classes. However, in this case, your div only has the .rectanglebox class.

Best regards!

Answer №3

It's functioning perfectly over here

.container.box {
  margin-top: 20px;
  margin-bottom: 20px;
  height: 180px;
  border: dashed black;
  padding: 15px;
}
<div class="container box">
  <p> example text </p>
  <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

Can a FontAwesome icon be used as a button in Bootstrap?

Hi there, I'm trying to use a fontawesome icon as a button in my code. Here is what I have so far: <!DOCTYPE html> <html lang="en"> <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" ...

Achieving equal column heights with objects that fill the entire space

Check out this CSS playground for experimentation: https://www.bootply.com/HHeQ3n0EbT https://i.sstatic.net/WVUpI.png <div class="container"> <div class="row"> <div class="col ltg-column-parent"> ...

Tips for performing addition with JSON data

How can I add up the values of qty in + (sum of qty) +? [{"qty": "34"},{"qty": "5"}] $.ajax({ url: "localhost/sp/text.json", //json link dataType: 'json', success: function(data) { var items = []; $.each(data, func ...

Tables lacking borders where rowspans are present

I'm currently using Firefox and have the following code snippet: html, body { width: 100%; height: 100%; } * { box-sizing: border-box; } body { padding-left: 20px; padding-right: 20px; } .visitentabelle { border: 2px solid black; ...

Arrange the navigation bar in a straight line

I am facing an issue with my navigation bar... I want it to be centered but it is not working. I want it to fill from left to right. I have tried using the following CSS: text-align: center in .navbar a text-align: center in navbar. .navbar { backgr ...

Unable to modify the .Css file for the VueJs plugin

I've been utilizing the vue-js-modal plugin and inside, there is a style.css file. I attempted to customize the modal style by making changes to this file, but even after saving my modifications and running the application, the modal page still reflec ...

CSS displaying inconsistently between Chrome and Firefox - seeking solution

I've encountered an issue with a CSS class named "titles" that seems to be working in Firefox, but not Chrome. Here's the code snippet: .titles { font-size: 4.5em; color: #154; text-shadow: 1px 2px #000; ...

Uploading JSON information retrieved from an API call into a MySQL database

Previously, I asked a similar question about passing JSON data to a dropdown menu using PHP. How can I arrange data array from an API request into an HTML SELECT OPTION LIST? Now, my goal is to insert the JSON data into a MySQL database. Here is my code ...

reveal or conceal content on hover of mouse pointer

I am currently working on a section that functions like jQuery tabs, but instead of requiring a click to activate, I want it to work on mouse hover. The current implementation is somewhat buggy - when hovering over a specific section, it displays as expe ...

Leveraging Laravel's bootstrap CSS to aesthetically enhance a specific section of a webpage

I'm attempting to utilize the default bootstrap css (app.css) provided by Laravel to style a specific section of my webpage - namely, the form section on my registration page. Instead of adding app.css directly to my html header and affecting other a ...

Prioritize loading iframes before other webpage content

My webpage includes an iframe, but the content within it only loads after all other content on the page has loaded. Is there a way to prioritize loading the iframe content before the rest of the page? Thanks! ...

Tips for placing <div .right> above <div .left> when the window is small, given that <div .right> is positioned to the right of <div .left> when the window is large

I've come across a similar layout before, but I'm struggling to replicate it myself. The idea is to have text aligned on the left side with an image floated to the right. Instead of the image appearing below the text when the window size is red ...

Creating an intranet website that can access a database dynamically without the need for a server or server side scripts is a

I have encountered a challenge where I need to create an Intranet webpage without the server for hosting. I have been attempting to update an Access database using HTML and javascript, but unfortunately, it is not working with the code below. Any assistanc ...

Utilizing CSS to manipulate the size of an image within an HTML tag by combining two separate

I'm currently working on a responsive website where I am trying to resize images using the CSS property transform:scale. It's important to me to maintain the aspect ratio of the images, so I have created two separate classes - one for landscape i ...

Creating color blends in CSS using overlapping layers

In my HTML structure, I have a div with the class "box" and I have utilized pseudo-classes :after to create a blue border around the box and :before to overlay an orange-colored box as shown in the image. I've achieved everything in the image - the bo ...

What's the best way to restrict characters in a paragraph?

I am working on an Angular application and I need to restrict the number of characters in a paragraph (p) to 50, after which it should break to a new line. Here is the template I am using: <section class="echeq-element-html-display border-box" [ng ...

The header in datatables.net is positioned on the side of the table rather than at the top

I am currently facing an issue with my datatables.net datatable. While all the columns and header are displaying properly, I am unable to position the header on top of the table. Instead, it appears on the side. Here's a visual representation: Curren ...

javascript, issues with floating and displaying elements

I am currently working on creating a JavaScript menu that has a click function to smoothly slide up and down. Although the JavaScript code appears to be functioning correctly, it seems that there is some interference with the CSS. Despite attempting vario ...

Using jQuery to trigger a click event on a radio button prevents the button from being checked

Having trouble with using the .trigger("click"); function on radio buttons to activate a button in a form. When I use the code below, the button is triggered as expected. However, it seems to be interfering with the radio button, causing it to appear chec ...

Control the transparency of the initial parent div that includes an *ngFor loop

I want to add opacity only to the first div which contains an icon and a heading in another nested div. The second div should remain fully visible (opacity: 1). Here is the HTML structure: <div class="row clearfix"> <div class="col-lg-3 col- ...