Struggling to rationalize a shape

I'm struggling with formatting my form on the webpage. I've tried using flex-shrink and resizing the width, but nothing seems to work. Can someone please help me center and align the space around my form properly?

Here is a snippet of my HTML:

body{
    font-family: sans-serif;
}

nav{
    background-color: rgba(69, 67, 67, 0.756);
}

/* Other CSS rules omitted for brevity */

form{
    display:flex;
    flex-direction: column;
    align-content: space-around;

}
<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="UTF-8>
      <title>Find the precious!</title>
      <link rel="stylesheet" href="style.css>
  </head>
  <body>
      <nav>
          <ul>
              <li>FindThePrecious.com</li>
              <li>Fellows</li>
              <li>Contact us</li>
          </ul>
      </nav>
      <section>
          <div class="carousel"></div<
      </section>
      <section>
          <h2 id="fellowsTitle"><a id="subtitle">(or alive if you want to eat them later)</a></h2>
      </section>
      <section id="fellows">
          <article><img src="https://via.placeholder.com/300x300" alt="blabla"/></article>
          <article><img src="https://via.placeholder.com/300x300" alt="blabla"/></article>
          <article><img src="https://via.placeholder.com/300x300" alt="blabla"/></article>         
      </section>
      <hr>
      <h2 id="contactUs">Contact us</h2>
     /* Form markup omitted for brevity */
  </body>
</html>>>

Answer №1

If you're looking to achieve a specific layout, one way is to add the margin attribute to your form:

form {
  display: flex;
  flex-direction: column;
  align-content: space-around;
  margin: 0 20px; /* You can also use padding here */
}

Here's an example of how this could be implemented:

body{
    font-family: sans-serif;
}

nav{
    background-color: rgba(69, 67, 67, 0.756);
}

li:first-child{
    font-size: 1.5em;
}

nav ul{
    display: flex;
    flex-flow: row wrap;
    width: 45%;
    height: 50px;
    color: rgb(233, 230, 230);
    list-style:none;
    margin-bottom: 0px;
    padding-left: 0px;  
}

ul li{
    display:flex;
    flex-flow: row wrap;
    align-items: center;
    justify-content:center;
    padding-left: 10px;
    padding-right: 10px;
    height: 100%;
    flex: 1 1 auto;
}

ul li:hover{
    background-color: rgba(255, 255, 255, 0.803);
    color: rgba(69, 67, 67, 0.756);
    border: 0.1px solid rgba(69, 67, 67, 0.756);
}

.carousel{
    width: 100%;
    height: 250px;
    background-color:rgb(204, 204, 204);
}

h2{
    display:flex;
    flex-flow: row wrap;
    vertical-align: end;
    line-height: 50px;
    text-align: center;
    color: rgba(69, 67, 67, 0.756);
    font-size: 1.5em !important;
}

#fellowsTitle{
    justify-content: center;
}

#subtitle{
    font-size: 0.5em;
    margin-top: 4px;
}

#fellows{
    display: flex;
    flex-flow : row wrap;
    justify-content: space-around;
    margin-bottom: 50px;
}

hr{
    margin-left: 20px;
    margin-right: 20px;
}

#contactUs{
    display:flex;
    flex-flow: row wrap;
    margin-left: 20px;
    
}

form{
    display:flex;
    flex-direction: column;
    align-content: space-around;
    margin: 0 20px;
}
<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="UTF-8>
      <title>Find the precious!</title>
      <link rel="stylesheet" href="style.css">
  </head>
  <body>
      <nav>
          <ul>
              <li>FindThePrecious.com</li>
              <li>Fellows</li>
              <li>Contact us</li>
          </ul>
      </nav>
      <section>
          <div class="carousel"></div>
      </section>
      <section>
          <h2 id="fellowsTitle">Fellows wanted dead &nbsp; <a id="subtitle">(or alive if you want to eat them later)</a></h2>
      </section>
      <section id="fellows">
          <article><img src="https://via.placeholder.com/300x300" alt="blabla"/></article>
          <article><img src="https://via.placeholder.com/300x300" alt="blabla"/></article>
          <article><img src="https://via.placeholder.com/300x300" alt="blabla"/></article>         
      </section>
      <hr>
      <h2 id="contactUs">Contact us</h2>
      <form>
          <input type="email" placeholder="@">
          <input type="text" placeholder="&#8962;">
          <input type="text" placeholder="I have seen one of them">
          <textarea placeholder="Your message"></textarea>
      </form>
  </body>
</html>

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

AngularJS provides the ability to use cookies when working with an EventSource

I'm exploring the idea of using EventSource to send server events to the client, but I want the client to be able to distinguish itself so it only receives its own events. I've been attempting to utilize cookies for this purpose, but for some rea ...

Replicating a website to use at a later time

I am brand new to the world of Javascript, currently diving into JavaScript and jQuery for an issue I'm facing. Here's what I'm trying to accomplish: I have a selection of words ("foo", "bar") Retrieve the current webpage's content ( ...

I can't find my unit test in the Test Explorer

I'm currently working on configuring a unit test in Typescript using tsUnit. To ensure that everything is set up correctly, I've created a simple test. However, whenever I try to run all tests in Test Explorer, no results are displayed! It appear ...

Understanding the scope of variables in JavaScript when using an anonymous function with addEventListener

Upon clicking on each div, an alert will display '1' if div 1 was clicked, or '5' if div 2 was clicked. This code has been simplified for ease of use in a larger application. <html> <head> <style type="text/css"> #div ...

Exploring jQuery's selection techniques involving filtering and excluding elements

How can I select all elements with the class .Tag that are not equal to the element passed to the function? Here is my current attempt: $("a.tag").filter(":visible").not("\"[id='" + aTagID + "']\"").each( function place(index, ele ...

Original selection unavailable in pagination

I'm encountering an issue on my website where Bootstrap and JQuery don't seem to work well together. $("ul.pagination li:not(.active) a").on("click",function(){ $(".pagination li.active").removeClass("active"); $(this).parent().addClass("activ ...

The AngularJS price slider may exceed its range if the ng-model is null or below the minimum value

I currently have an rz-slider featured on my webpage that is utilized for gathering the price of a product from the user. In addition to the slider, there are two input fields present which are designated for storing the minimum and maximum values. The ng- ...

Updating children of specified parents using jQuery

I have a collection of files in a directory and some file icons need to be changed as the default ones are not specific enough. Due to limitations, I can only achieve this using jQuery to insert the code since the mimetype function cannot be modified. Bel ...

Discovering the method to retrieve the information of the selected item in AngularJS

My table is using the ng-repeat in the <tr> element to load content dynamically from a JSON file. Each row has a unique ID in the table. I need a way to access the inner HTML of the respective row's ID column when it is clicked. Is there a solut ...

Incorrect modal placement

I am new to CSS and currently working on customizing a modal window. My main issue lies with its positioning, especially when the browser resolution changes, causing a misalignment as seen in the screenshot. I would like to specify the width and height dim ...

How can you apply the ngStyle directive to set the CSS property for the Angular Material Data Table header aligning it to

For this demonstration, I am attempting to dynamically set the left CSS property of the CUSTOMER mat-header-cell to 64px using ngStyle. However, it seems that Angular is overriding the value with its own interpretation, changing it to 216px after applying ...

Javascript: Issue with loading image resource onto a specific div element

Seeking guidance on how to display the actual image resource on a div tag: Here is the script in full: var smileys = []; smileys[":)"] = "happy.png"; smileys[":D"] = "laugh.png"; smileys[":3"] = "meow.png"; smileys[":{"] = "must.png"; smileys[":V"] = ...

Using SVG and CSS to color multiple paths with individual colors

I am working with an svg that contains various paths, ellipses, and shapes each with different fill colors such as red and blue. When I combine them into a sprite, I want to be able to change the fill color on hover using CSS. Typically, I would remove the ...

Header becomes distorted while scrolling down, then returns to normal when scrolling back up

Something strange is happening on my client's website. Whenever I scroll down and then back up, the header displays a large white area where the address/contact bar should be. You can see it in action on the site: rijschool-wolvega.nl I'm not w ...

Having trouble with CSS basics? Seeing properties change across multiple classes?

My CSS skills are still in the beginner stage and I am currently struggling to troubleshoot an issue with my code. The HTML: <div id="loginForm"> <span class="dottedLink"><a href="resetlogin">Recover login details</a></span ...

You cannot link to the innerHTML containing bookmarks from a different page

Using JavaScript AJAX, I am including a file called cards.html into a parent HTML page named index.html. The included cards.html file consists of a list of cards, each containing a bookmark in the form <li id="byx-123_shapes">. However, w ...

Having trouble with the linear gradient color length in HTML?

I'm attempting to design a gradient background using HTML and CSS. The gradient I want should be red for the top 10% and green for the remaining 80%, similar to this example: https://i.sstatic.net/TlnIh.jpg To achieve this, I came up with the follo ...

It is impossible for JavaScript to set the position attribute directly in the element's style property

I'm new to javascript and I need some help. I created a function that adds a div with the id "test_div" to the body. However, when I try to set the position using "element.style.position", it doesn't work. I figured out that I can apply styles us ...

Automatically refresh browser tabs with the most up-to-date web page

As a newcomer to html, I find it frustrating to have to constantly refresh my browser every time I make changes. I am currently using vs code and wondering if there is another code editor that can automate this process for me or perhaps a different browser ...

What could be causing the shift from querySelector to querySelectorAll to result in an undefined outcome?

When I switched from using querySelector to querySelectorAll, I encountered an issue where it returned undefined. I have double-checked the spelling of the class names and they are correct. This led me to believe that there might be something else overlook ...