The content extends far beyond the boundaries of the box area

Check out my codepen: http://codepen.io/Chiz/pen/zBWzZB

I am trying to position the UL list inside the white area on the left side, but for some reason, it keeps extending beyond the boundaries of the white area.

However, when I remove the UL tag, everything looks fine.

* {
  box-sizing:border-box;
}

body {
background: linear-gradient(to right, #f4f4f4 0%,#848484 80%);
}

.container {
  width:100%;
  height:100vh;
  position:relative;
}

.card {
  width:70%;
  height:500px;
  background-color:rgb(250,250,250);
  padding:0;
  position:absolute;
  top:50%;
  left:0;
  right:0;
  margin:0 auto;
  transform:translateY(-50%);
}

.card .left {
  width:70%;
  height:100%;
  background-color:rgb(250,250,250);
  display:inline-block;
  padding:0;
  margin:0;
}

.card .left .leftcontentbox {
  width:75%;
  height:90%;
  border:1px solid red;
  margin:0 auto;
}

.card .left .leftcontentbox .topnav {
  width:100%;
  border:1px solid black;
}

.topnav ul li {
  display:inline-block;
}

.card .right {
  width:29.55%;
  height:100%;
  background-color:#b6e6f2;
  display:inline-block;
  padding:0;
  margin:0;
}
<div class="container">
<div class="card">
<div class="left">
<div class="leftcontentbox">
<div class="topnav">
<img src=""></src>
<ul>
<li>Articles</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>

<div class="headertext">

</div>

<div class="latestarticles">

</div>

</div>
</div>


<div class="right">
</div>
</div>
</div>

Answer №1

To align your cards, add a float left to the left card class and a float right to the right card class:


{
  box-sizing:border-box;
}

body
{
background: linear-gradient(to right,  #f4f4f4 0%,#848484 80%);
}

.container
{
  width:100%;
  height:100vh;
  position:relative;
}

.card
{
  width:70%;
  height:500px;
  background-color:rgb(250,250,250);
  padding:0;
  position:absolute;
  top:50%;
  left:0;
  right:0;
  margin:0 auto;
  transform:translateY(-50%);
}

.card .left
{
  width:70%;
  height:100%;
  background-color:rgb(250,250,250);
  display:inline-block;
  padding:0;
  margin:0;
  float: left;
}

.card .left .leftcontentbox
{
  width:75%;
  height:90%;
  border:1px solid red;
  margin:0 auto;
}

.card .left .leftcontentbox .topnav
{
  width:100%;
  border:1px solid black;
}

.topnav ul li
{
  display:inline-block;
}

.card .right
{
  width:29.55%;
  height:100%;
  background-color:#b6e6f2;
  display:inline-block;
  padding:0;
  margin:0;
  float : right;
}

Answer №2

Swapping display:inline-block with float:left in the .card .left section and using float:right in the .card .right section.

After applying float to both .left and .right, it is necessary to reset the float by assigning the .fixit class to the parent element (.card) of .left and .right

Note: The CSS code for the .fixit class is also provided below

.fixit:after{visibility:hidden;display:block;font-size:0;content:" ";clear:.req-a-quote input[type="submit"]both;height:0;}
.fixit{display:inline-block;clear:both;}
* html .fixit{height:1%;}
.fixit{display:block;}

* {
  box-sizing:border-box;
}

   .fixit:after{visibility:hidden;display:block;font-size:0;content:" ";clear:.req-a-quote input[type="submit"]both;height:0;}
.fixit{display:inline-block;clear:both;}
* html .fixit{height:1%;}
.fixit{display:block;}

body{
background: linear-gradient(to right, #f4f4f4 0%,#848484 80%);
}

.container{
  width:100%;
  height:100vh;
  position:relative;
}

.card{
  width:70%;
  height:500px;
  background-color:rgb(250,250,250);
  padding:0;
  position:absolute;
  top:50%;
  left:0;
  right:0;
  margin:0 auto;
  transform:translateY(-50%);
}

.card .left{
  width:70%;
  height:100%;
  background-color:rgb(250,250,250);
  float:left;
  padding:0;
  margin:0;
}

.card .left .leftcontentbox{
  width:75%;
  height:90%;
  border:1px solid red;
  margin:0 auto;
}

.card .left .leftcontentbox .topnav{
  width:100%;
  border:1px solid black;
}

.topnav ul li{
  display:inline-block;
}

.card .right{
  width:29.55%;
  height:100%;
  background-color:#b6e6f2;
  float:right;
  padding:0;
  margin:0;
}
<div class="container">
  <div class="card fixit">
    <div class="left">
      <div class="leftcontentbox">
        <div class="topnav">
          <img src=""></src>
          <ul>
            <li>Articles</li>
            <li>About</li>
            <li>Contact</li>
          </ul>
        </div>

        <div class="headertext">

        </div>

        <div class="latestarticles">

        </div>

      </div>
    </div>


    <div class="right">
    </div>
  </div>
</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

Implementing nth-child selector in vanilla JavaScript

Is there a way to dynamically change the number within the nth-child brackets when clicking on a button? For instance, can I click a button and have the next slide in a slideshow appear? .slideshow:nth-child(n){} I specifically need to modify n using only ...

I'm attempting to include a home glyphicon in my navigation bar using a bootstrap class. Unfortunately, it doesn't appear on the output page. Any suggestions for resolving this issue?

I'm having trouble adding a home icon using Bootstrap glyphicon; it's not appearing in the output. Can someone assist me with this? I've already attempted to increase the font size and change the font color, but neither solution worked. &l ...

What is the reason for Internet Explorer making a POST request upon clicking <a><button/></a>?

Here's the structure of my form: <form method="post"> {% csrf_token %} <table> {% for field in form %} {% partial "partials/field.html" field=field %} {% endfor %} <tr> <td& ...

The alignment issue of Owl Carousel card being off-center

I can't seem to get my owl carousel properly centered on my website. I've set up the owl carousel to showcase customer testimonials on my landing page, but it's slightly off to the right and not aligning correctly with the testimonial title. ...

Ways to modify the color of a selected dropdown in a navigation bar

Every time I click on the dropdown menu, it gets highlighted in blue. Is there a way to change this using Bootstrap or by adjusting my CSS? I've already attempted changing the color with this CSS element: .dropdown-item.active, .dropdown-item:active ...

Why isn't the MVC AjaxOption displaying the spinner in the correct location?

I am attempting to display a spinner on an overlay within a partial view while loading another partial view. However, it is displaying where the div was originally declared. Index.cshtml <div id="DivEmailContainer" style="display:block" class="row"> ...

Issue with importing and exporting JavaScript on an HTML file is not functioning as expected

I recently worked on a basic JavaScript project involving export/import and encountered an error when inserting it into the HTML. The error message read: "Uncaught SyntaxError: Cannot use import statement outside a module". I researched this issue on Stack ...

Is it possible to prioritize CSS selectors in a specific sequence?

I possess a pair of div elements: div class="one two three" div class="three two one" Is it probable to formulate a CSS regulation that exclusively focuses on ".one.two.three" and does not encompass ".three.two.one" ? ...

Navigate to the website and display it within the central frame, utilizing the bootstrap vertical tabs layout

I recently obtained a bootstrap template that features vertical tabs along with a main frame. Check out the current view of the webpage here My goal is to have the ability to click on 'Google' (the link on the left) and have the Google page loa ...

What is the best way to retrieve JSON data values for buttons that have been clicked and files that have

Is there a way to retrieve JSON data only for clicked buttons and uploaded files? Currently, I am receiving all button values, whether clicked or not, in one instance, and file paths with fake paths like C:\\fakepath\\test.txt in anothe ...

How can Selenium click on an <a> element using By.LinkText and bypass any line breaks within the link text?

One a element contains text with \r\n within it. The HTML code is shown below: <a href="/Profile/ProfileView?isSuccessScreen=1&amp;URLID=x/ayvqzf7zojzzqiauihka" class="list green profile "> <img src="/content/css/theme/images/pro ...

Voting Dynamics in Django: Ordering by Popular Vote

There is a lot of existing documentation on this topic, but so far, none of the solutions have worked for me. As the title suggests, my goal is to sort a set of objects using Django Voting based on the number of votes they have (from high to low). I have a ...

Middle align an absolutely positioned block within a table cell vertically

Here is the code I am working with: td { border: 1px solid #cecece; position: relative; padding: 80px 20px; } .hint { background: yellow; position: absolute; top: 0; bottom: 0; left: 100px; } <table style="width:800px"> <tr> ...

Adding vulnerable flash elements to a protected webpage

Is it feasible to incorporate a YouTube video into a secure https website? It appears that YouTube videos can solely be embedded using the http:// protocol. Is there a workaround to embed them on a page without triggering an error in Firefox? ...

How does having several CSS files, even if they are small, impact the loading speed of my website

MY CURRENT SITUATION I am working with multiple pages such as index.html and menu.html, all using a single stylesheet called style.css. A large portion of the styling code used for index.html is not necessary for menu.html. MY QUESTION Should I consid ...

Show a stack of canvas elements on top of one another

I am working with 2 canvas elements that are identical in size and position. The first canvas is meant to serve as the background, while the second one will display the scenes. However, when I run my code, only the canvas that was loaded first in the HTML ...

tips for extracting data using jQuery .html method

Can anyone assist me in extracting values from the jQuery .html() function with the provided code snippet? $('#div_id').html('<input name="textbox1" id="txt1" type="text" size="40" maxlength="350">'); This code functions by crea ...

Mastering jQuery placement using CSS3 "transform: scale"

There seems to be an issue with jQuery not functioning well with CSS "transform: scale()" (however, it works fine with "transform: translate()") Please examine this straightforward example: $(document).ready(function() { $('#root').dblclic ...

Design a table where the thead element is larger in width compared to the overall width of

My table is very basic, consisting of 3 rows and 3 columns. I am attempting to make it resemble the layout shown in this image https://i.sstatic.net/31nIN.jpg (specifically, the thead should have a greater width than the other rows). How can I achieve th ...

How to use jQuery to retrieve the height of the elements inside a specific container

I'm uncertain if it's feasible, but I am looking to determine the total height of the content within a specific container. Imagine I have <div id="container" style="min-height:100vh"> <div class="child"> <p>Some text ...