CSS formatting difficulties

Recently, I decided to experiment with Sass and created a small, simple webpage. However, I encountered an issue where adding a top-margin to #content affected the wrapper div instead. If anyone has insight into why this is happening, I would greatly appreciate it. Thank you!

To view the live page, click here:

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />

<title>YO</title>

</head>

<body>

<div id="wrapper">

<div id="content">

<div class="dog">
Bury me with my money
</div>

</div>

</div>
</body>
</html>

Sass:

html body
    background-color: #000
    padding: 0
    margin: 0
    height: 100%

#wrapper
    background-color: #fff
    width: 900px
    height: 700px
    margin: 0 auto

#content
    width: 500px
    margin: 150px 0 0 50px  

.dog
    color: #FF3836
    font-size: 25px
    text-shadow: 2px 2px 2px #000
    width: 500px
    height: 500px
    -moz-border-radius: 5px
    -webkit-border-radius: 5px
    border: 18px solid #FF3836

CSS output from Sass:

html body { background-color: #000; padding: 0; margin: 0; height: 100%; }

#wrapper { background-color: #fff; width: 900px; height: 700px; margin: 0 auto; }

#content { width: 500px; margin: 150px 0 0 50px; }

.dog { color: #FF3836; font-size: 25px; text-shadow: 2px 2px 2px #000; width: 500px; height: 500px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border: 18px solid #FF3836; }

Answer №1

Great job on your work so far! One key element you should include is float: left. Update your code to look like this:

#main-section { width: 800px; margin: 200px 0 0 100px; float: left; }

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

Smooth Transition When Page is Fully Loaded

Is it possible to apply a saturation effect with ease-out to my logo once the page is loaded, or does it only work with "hover"? Here is the code I'm using: /* CSS*/ #logo { -moz-transition: all 7s ease-out; -o-transition: all ...

Select Multiple Checkboxes in Bootstrap/HTML

Is there a way to make it so that selecting one checkbox will automatically select all the others in Bootstrap/HTML? ...

It seems that in Laravel 5.3, it's challenging to add a script to a view for an autocomplete

Currently, I am working with Laravel 5.3 for my internship. However, I have encountered a frustrating issue that I need help with: I am trying to implement an "autocomplete" field on a page, but it doesn't seem to be functioning correctly. The error ...

Utilizing a responsive design with a bootstrap grid system, featuring expandable columns for

After creating a bootstrap grid page, I am facing an issue with the layout on mobile screens. My problem arises when trying to reorder the cards properly for mobile view. Here is my current logic: <div class="row"> <div *ngFor="let col of [1, ...

JavaFX WebView showcases HTML content differently compared to Libre Office Writer

After using SceneBuilder 2 to create a Dialog for displaying Help documents in a WebView, I proceeded to generate an HTML document in Libre Office Writer. Upon loading the 'Help.html' file, I noticed that the line spacing in the WebView differed ...

The concept of promises and futures in JavaScript bears a resemblance to the functionality present

Is there a JavaScript library that offers promises and futures with syntax similar to C++? We need to use them in webworkers without a callback interface. I want the webworker to pause on a future and resume when the UI thread assigns a value to it. I ha ...

Unique Menu: Challenge when adjusting the width of 5 divs upon hovering while maintaining full site width at 100%

I'm looking to create a sleek custom menu with 5 fields. I want the field under the mouse to expand in width on mouseover, while the other fields shrink in width. The issue I'm facing is that the transition effect is not smooth and the total wid ...

The sizing of table rows within a card body appears to be incorrect while using Bootstrap 4

Within a card element, I have a table where one of the cells contains a progress bar. Unfortunately, the width of this specific column is not rendering as desired (col-xs-8). I've attempted adjusting the width on table headers and specific data column ...

Activate unresponsive state when clicked

Struggling to implement a mobile responsive menu, my primary issue is the navigation buttons not toggling upon clicking. Here's what I have so far in terms of HTML and JQuery: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery. ...

What could be the reason for the onClick event functioning only once in HTML?

Below is the code snippet containing both HTML and JavaScript. However, the issue I am facing is that the onclick event only seems to work for the first <li>. <!DOCTYPE html> <html> <body> <ul class="list"> <li ...

PHP function with JSON response encountered an error during the AJAX call

I am currently working on creating a News Ticker that utilizes PHP, Javascript, and AJAX. The first step involved creating a PHP function called getFeed(), which gathers data from various news websites into an Array. This data is then returned in JSON form ...

In the case of a PDF being in landscape orientation, the full width of the document is not utilized despite the width being set to

Even though I have specified the width of the Header table to be 100% and applied a margin-right of 1cm for PDF reports with landscape orientation, the table is not taking up the full width. However, when my PDF report has portrait orientation, the header ...

What steps do I need to take in Bootstrap 5 to add a search icon to the navbar that reveals a search box beneath it when clicked?

I've made progress on the navbar design Now, I'm looking to add a search icon next to the login button. Clicking on the search icon should reveal a search box below the navbar, similar to the image shown below. My transparent navbar has a relati ...

Designing Boxes with Specific Positioning and Dimension Measurements

As someone new to the world of HTML and CSS, I am currently working on creating colored filled boxes that fit within a border box. The challenge is to ensure they are set at specific width and height dimensions, while also being positioned exactly 2px apar ...

Managing text size in HTML email designs

How can I maintain consistent font sizes in HTML EMAILS? The fonts look great on the website, but in my email they appear small and close together. Check out Live Demo I've attached a screenshot of how the email appears to me. Any suggestions on h ...

What is the best way to implement a reusable HTML navbar across multiple pages of my website?

I have incorporated Bootstrap 4 into my website design. Currently, I'm including the same navbar code on every page. However, whenever I need to update the navbar, I find myself copying and pasting the code across each page. Is there a way for me to ...

What's the best way in Angular 6 to set focus on an element that's being made content editable?

I am currently utilizing the contentEditable attribute in Angular 6 to allow for editing the content of elements within an ngFor loop. Is there a way to focus on a tag element when its contentEditable attribute is set to true? <div class="tag" *ngFor= ...

What is the best way to adjust the size of an image within a div element using HTML?

I've created a Carousel with 5 images to display. However, I'm having an issue where only the image is showing up, and I want the text and button to appear below it. Here's how the nature image is currently displaying: What I want is for th ...

Replacing the tbody element in React with centered text using inline styles ---If you want

I am working with an empty array in React that I translate into state. When the array is empty, I want to insert a text that says "no match events yet..." into a react-bootstrap Table's tbody. In the current setup, I am struggling to center the text ...

Any tips on how to effectively integrate dynamic theming in CSS?

I am currently developing a theming feature for my web application, allowing users to select a theme that will dynamically change the color of various elements. Here is an example of the theme selector: <div id="theme-selector"> <div id="theme- ...