Creating a webpage for a student project using HTML and CSS

I have a piece of code labeled as "vertikalni" and "baner". My goal is to place that section under the header and make it horizontal. The size of this section should match that of the header.

The vertical one doesn't necessarily have to stay in its current position, I just need to switch their placements. However, whenever I try to swap them using HTML and CSS, it ends up disrupting my entire layout.

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

body {
  background-color: #EEE;
}

#wrapper {
  margin: 0 auto;
  background-color: #CCC;
  border: 5px solid #000;
  width: 692px;
  /*750-2x5-2x24=692*/
  padding: 24px;
}

header {
  border: 2px solid #000;
  height: 46px;
  /*80-2x2-2x15=46*/
  background-color: #FFF;
  padding: 15px;
  margin-bottom: 24px;
  /*ili u delu ispod margin-top*/
}

#slika {
  width: 204px;
  /*238-2x15-2x2=204*/
  height: 366px;
  /*400-2x15-2x2=366*/
  border: 2px solid #000;
  background-color: #FFF;
  margin-left: 24px;
  padding: 15px;
  float: left;
}

#pesma {
  background-color: #FFF;
  width: 254px;
  /*306-2x2-2x24=254*/
  height: 348px;
  /*400-2x2-2x24=348*/
  border: 2px solid #000;
  padding: 24px;
  float: left;
}

#vertikalni {
  width: 100px;
  margin-left: 24px;
  /*ili u divu pesma margin-right*/
  margin-bottom: 24px;
  float: left;
}

footer {
  background-color: #FFF;
  height: 18px;
  /*70-2x2-2x24=18*/
  padding: 24px;
  border: 2px solid #000;
  clear: left;
}

footer p {
  margin: 0px;
}

.baner {
  width: 98px;
  /*100-2x1=98*/
  height: 98px;
  /*100-2x1=98*/
  border: 1px dashed #000;
  background-color: #999;
  float: left;
}

img {
  width: 198px;
  /*202-2x2=198*/
  border: 2px solid #000;
}
<div id="wrapper">
  <header>
    <p>Our greatest poets in the history of literature</p>
  </header>
  <div id="pesma">
    <h1>Magic Doors</h1>
    <p>In a world there exists,<br> full of all kinds of treasures,<br> And everything it has — shared with everyone,<br> In that lies its strength.</p>
    <p>If you want houses, there are plenty,<br> Just take and build,<br> If bridges you seek, call on people,<br> Construct a giant bridge.</p>
    <p>If songs you desire, they echo within,<br> Millions sing in harmony,<br> Each beckons you to work there,<br> Yet none compel you to stay.</p>
  </div>
  <div id="vertikalni">
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
  </div>
  <div id="slika">
    <img src="images/mira.jpg" alt="Portrait">
    <p><b>Mira Alečković</b></p>
  </div>
  <footer>
    <p>This task's content was sourced from <a href="http://www.wikipedia.org">Wikipedia.</a></p>
  </footer>
</div>

Answer №1

To resolve this issue, follow these step-by-step instructions:

  1. Firstly, reposition the #vertikalni div to be located directly under the header tag.
  2. Adjust the width of the #silka and #pesma divs to 42% to match the width of the header above them.
  3. Include margin-bottom: 24px in the #silka div to create space for the footer tag below it.
  4. Delete width: 100px; margin-left: 24px; to align the width with the header.

body {
  background-color: #EEE;
}

#wrapper {
  margin: 0 auto;
  background-color: #CCC;
  border: 5px solid #000;
  width: 692px;
  /*750-2x5-2x24=692*/
  padding: 24px;
}

header {
  border: 2px solid #000;
  height: 46px;
  /*80-2x2-2x15=46*/
  background-color: #FFF;
  padding: 15px;
  margin-bottom: 24px;
  /*ili u delu ispod margin-top*/
}

#slika {
  width: 42%; /* Step 2 */
  /*238-2x15-2x2=204*/
  height: 366px;
  /*400-2x15-2x2=366*/
  border: 2px solid #000;
  background-color: #FFF;
  margin-left: 24px;
  padding: 15px;
  float: left;
  margin-bottom: 24px; /* Step 3 */
}

#pesma {
  background-color: #FFF;
  width: 42%; /* Step 2 */
  /*306-2x2-2x24=254*/
  height: 348px;
  /*400-2x2-2x24=348*/
  border: 2px solid #000;
  padding: 24px;
  float: left;
}

#vertikalni {
  /* Step 4 */
  /*ili u divu pesma margin-right*/
  margin-bottom: 24px;
  float: left;
}

footer {
  background-color: #FFF;
  height: 18px;
  /*70-2x2-2x24=18*/
  padding: 24px;
  border: 2px solid #000;
  clear: left;
}

footer p {
  margin: 0px;
}

.baner {
  width: 97px; /* Step 5 */
  /*100-2x1=98*/
  height: 98px;
  /*100-2x1=98*/
  border: 1px dashed #000;
  background-color: #999;
  float: left;
}

img {
  width: 198px;
  /*202-2x2=198*/
  border: 2px solid #000;
}
<div id="wrapper">
  <header>
    <p>Our Greatest Poets in Literary History</p>
  </header>
  <!-- Step 1 -->
  <div id="vertikalni">
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
    <div class="baner"></div>
  </div>
  <div id="pesma">
    <h1>Magical Gates</h1>
    <p>In a world there exists,<br> filled with all treasures,<br> and everything she has — shares with everyone,<br> in that lies her strength.</p>
    <p>If you want houses, she has them,<br> just take and build,<br> bridges you want, call people,<br> construct gigantic bridge.</p>
    <p>If you want poems, they echo within her,<br> millions sing aloud,<br> everyone calls you there to work,<br> yet no one drives you away.</p>
  </div>
  <div id="slika">
    <img src="images/mira.jpg" alt="Portrait">
    <p><b>Mira Alečković</b></p>
  </div>
  <footer>
    <p>This task content was derived from <a href="http://www.wikipedia.org">Wikipedia.</a></p>
  </footer>
</div>

Answer №2

To start, place the "vertikalni" div below your header in the HTML file so it appears where you want it to be displayed. Since your header is within the wrapper, setting the width of #vertikalni to 100% will make the banner divs appear horizontally. The banner divs have a restricted width of 98px, making them shorter than the header. With a width of 100% divided by 4 divs, each div should be set to 25%. By adjusting the width to 25%, the divs will fit perfectly without overflowing, but remember to remove any margin-left to prevent overflow.

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

A workaround for background-size in Internet Explorer 7

Currently, I am working on a project at this link: Everything seems to be functioning well in Firefox and Chrome, however, I have encountered an issue with the background-size property not being supported in IE7. I heavily rely on this property throughout ...

Is it possible to include a preloaded "busy" animation on the page?

My current setup involves a simplified version of the attached code in order to focus on getting the basics to work initially. The input text from the textbox is being used as a variable in the PHP file 'testnewsearchresults.php'. Upon running t ...

The KeyboardAvoidingView disrupts the structure of the flexbox layout

Check out this code snippet: return ( <KeyboardAvoidingView style={{ flex: 1 }} behavior="padding" enabled> <View style={style.flex1}> <View style={style.imageContainer}> <Image style={style.image} ...

How to Solve the Frustrating Problem of Ensuring Page Content 100% Height of Document

Currently, I am in the process of creating the second version of my new web app called Trekeffect. My main goal is to ensure that the interface content takes up 100% of the page's height. However, despite my best efforts, I haven't been successfu ...

What's the best way to align a bottom navigation bar in the center?

Hey there! I recently added a bottom navigation bar to my website using HTML and CSS code. However, I'm having trouble centering it at the bottom of the page. Any suggestions or solutions would be greatly appreciated. Attached are screenshots of the H ...

Having difficulty showcasing the JSON data within the dropdown list within an HTML table

In my HTML table, I have 4 rows with Order ID and Product Comments columns disabled. Users can enter data in other columns and submit it. Upon submission, I receive a JSON object which I iterate through and display in the table. I am facing two challenges ...

When interacting with elements with the "user-select: none" property, WkWebView still allows text selection

When using an iOS iPad app with a single fullscreen WKWebView, an issue arises when long-pressing on an area with user-select:none - the first text in the next available area without user-select:none gets selected instead of being ignored. Is there a way t ...

Discovering elements using the XPath in Selenium WebDriver

Imagine you have a website: <div class="formfonttitle">Wireless - General</div> <div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/New_ui/export/line_export.png"></div> <div c ...

Is there a way to embed an AJAX submit form into a notification without the need for page refresh?

I have integrated the jQuery plugin toastr js () for notifications on my website. I am facing an issue where I want to include a contact form within the notification popup and submit it using AJAX. Despite having the form working fine outside of the toastr ...

I'm having trouble getting jQuery UI's droppable to function properly. How can I troub

Recently, I created a drag and drop game to enhance my jQuery UI skills. However, I am facing an issue where the circle cannot be dropped on the square with the same color. Also, when it does work, the circle ends up behind the square instead of on top. It ...

Transferring data from an anchor tag using AngularJS

Within my php website, there is a button with an anchor tag embedded in it that transmits a numerical value to the Angular application; echo "<button data-toggle='tooltip' type='submit' data-placement='bottom' title='$ ...

What is causing the space between the images in my flex column?

I am trying to create a layout with two columns and two rows. The first row should have text in the first column and an image in the second column, while the second row should have an image in the first column and text in the second. My goal is to make th ...

Guide to Positioning Pre-Loader in the Center on Mobile Devices

Despite trying numerous solutions, I'm struggling to center my pre-loader on mobile devices. It looks fine on desktop and mobile landscape orientations, but whenever I switch to mobile portrait, it just won't center properly. CSS: .load ...

Unusual display of fonts on Chrome

Recently, I encountered a strange issue with font rendering on Chrome/Opera compared to Firefox. The problem can be seen in the preview below - pay attention to the pink text. It appears blurry initially but sharpens once text input is focused. This same i ...

Is there a way to determine if a parent of my HTML element possesses a CSS class?

Looking at this HTML code snippet - <div id="parent" class="foo"> <div id="child"> </div> </div> Is there a way to create a test to verify if the child element is utilizing the foo class? I attempted: element .children("#chi ...

IE8 Image Links Not Working Without Chrome Frame Enabled

Upon visiting the website below, you'll notice a slideshow featured at the top of the homepage. Utilizing Nivo Slider, our client has brought to our attention that the links are not operational in IE8. The issue may be related to the "slide-overlay" ...

"Fixing issue with Checkbox not getting checked using a combination of jQuery and

My array called `totalCheckBoxArray` contains the values [1, 2, 3]. I also have checkboxes with values 1, 2, and 3: <div class="card-body"> <h5>Document List</h5> <div class="form-check"> ...

Applying a dynamic translate3d transformation on the ::after element using CSS3

My current challenge involves manipulating a pseudo ::after element using translate3d If I hardcode the values, it's straightforward: div::after { ... transform: translate3d(40px, 40px, 0); } Now, I want to dynamically set the value for the ...

Click event form validation not functioning in JavaScript

Hello, I am currently setting up validation for input fields on keyup and when the submit button is clicked. I have opted not to use input type submit to avoid reloading the page after submitting the form. The logic is that if the input field is empty or ...

In relation to CSS and HTML

I recently started working on a website built with HTML/CSS and encountered an issue with links highlighting when hovered over. The problem arises from the main image on the homepage containing an embedded link, causing the area under it to also highlight ...