Setting size using percentages in Semantic-UILet's explore how to define the size

Since discovering semantic-ui a few days ago, I've been impressed and have decided to switch my app from Bootstrap 3 to semantic-ui.

I could use some assistance here. I'm attempting to split the body of the page into two parts. I would like the height of the two divs to be in percentages, specifically 85% and 15%, totaling 100%. However, for some reason, it's not working as expected.

body {
height: 100%;
width: 100%;
}
#div1 {
height: 85% !important;
border: 1px solid #000000;
}
#div2 {
height: 15% !important;
}

Could someone point out what I might be doing wrong? This method worked fine in bootstrap. Any insights on this issue would be greatly appreciated!

Thank you in advance, Praney

Answer №1

Illustration of Semantic IU Grid system.

<div class="ui grid">
<div class="equal height row">
    <div class="twelve wide column">

            <p>You inquired about vertical percentages, however, presenting an instance showcasing the equal height rows feature in Semantic UI's grid system. This ensures that a dominant column like this aligns in height with others in the same row, permitting a div below without any overlapping issues. This segment occupies three-quarters of the width (twelve blocks out of sixteen). It adjusts according to the content's height. </p> 

    </div>
    <div class="four wide column">

           <p>The compact column</p>

    </div>
</div>

<div class="row">
    <div class="sixteen wide column">
        <div class="ui segment"> 
             <p> This represents the boxed footer as it is enclosed within a div with the class name "ui segment".</p>
        </div>
    </div>
</div>

By eliminating the term 'stackable', the layout ceases to be responsive. Include the term 'page' in the initial list to establish a maximum width on larger screens.

Answer №2

In order for this to function properly, your body must have a specific height:

body {
height: 800px;
width: 100%;
}
#section1 {
height: 85% !important;
border: 1px solid #000000;
}
#section2 {
height: 15% !important;
border: 1px solid #000000;
}

JSfiddle: http://jsfiddle.net/48Eh7/

However, it may not be necessary to set fixed heights for the div elements as they will expand based on their content.

If you simply want a footer at the bottom of the page, you can achieve that with the following HTML code:

<div>
    <p>Content goes here...</p>
</div>
<div>
    <p>Footer content</p>
</div>

No need for additional CSS styling in this case.

Answer №3

After experimenting extensively, I discovered that semantic-ui does not allow for styling on the document body.

To address this issue, I had to nest #div1 and #div2 inside the #container div and apply the following styles:

#container {
height: 100vh;
}
#div1 {
height: 85% !important;
border: 1px solid #000000;
}
#div2 {
height: 15% !important;
}

By containing the divs as follows:

<div id="container">
  <div id="div1"></div>
  <div id="div2"></div>
</div>

This solution worked effectively. I wanted to share this workaround so that others facing the same issue can benefit from it.

Sincerely, Praney

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

limited growth of float variable

I am utilizing CSS code to create column a and column b, using float in the code to dynamically expand column a as content is added to column b. However, this expansion is not occurring as expected. To see my code, please visit http://jsfiddle.net/hadinetc ...

submitting image data from HTML5 canvas using an HTML post request

I am having issues sending canvas data to the server side as an image. Despite making an HTTP post request, I am unable to retrieve the data on the server side. $_POST remains empty, even though I can see the image data when console logging the object on t ...

When clicking on HTML input fields, they do not receive focus

I am facing a puzzling issue where I am unable to access the input fields and textareas on my HTML form. The JS, HTML, and CSS files are too large for me to share here. Could someone provide guidance on what steps to take when troubleshooting this unusual ...

Picking and modifying a newly added HTML input element using Jquery

I am encountering a problem that I haven't been able to find a solution for through research or Google. I managed to successfully add multiple input boxes to my HTML/JQuery project, which are displaying correctly on the webpage. for (i = 0; i < ma ...

Making Adjustments to the Padding of Main Content Column in Typo3 Using Bootstrap Package

As the administrator of our local sports club's homepage, I oversee svwalddorf.de, powered by typo3 10.4.22 with bootstrap package 11.0.3. The current bootstrap template creates excessive empty space around the centered content area as shown here. Th ...

How can I set the text to be in the center of a VML

For my email template, I need to center text over an image. Although I attempted a solution from this source, the image is not being displayed. Below is the code snippet: <div align="center" style="margin: 0; padding: 0;"> <table border="0" c ...

Addressing some minor visual inconsistencies in an HTML bullet-pointed list

After reviewing my current code, it is displaying the following: https://i.stack.imgur.com/dvjrc.jpg I am attempting to make the following changes: Ensuring each line in the list fits properly within its corresponding box by utilizing vertical-align: to ...

I would appreciate your assistance in the modification of the input type from text to radio within the PHP code

I've been struggling to update the input type from text to a radio button for Gender selection in my Wordpress theme's user profile settings. I can't seem to get it right in the code and I'm not sure how to make the change. I tried usi ...

The homepage is not converting to a different language

Using the WPML plug-in for my WordPress website has been successful in translating most of my pages, but I am running into an issue with the home page. Even though I have manually translated and published the home page, it still does not translate when cli ...

Damaged background in Bootstrap interface modal

https://i.stack.imgur.com/nTAnK.png Is there anyone who can assist me in identifying the issue causing the broken or irregular backdrop in the background of overlays or pop-ups? $scope.Modal = $modal.open({ animation: true, ...

Trying to decide between using a Javascript or HTML5 PDF Editor?

I am in need of a solution that enables users to edit PDF files directly on an ASP.NET web page. This functionality is intended for creating templates and adding blocks/form fields to existing PDFs, complete with rulers and other necessary features. Desp ...

Only output to the console if the data returned from an AJAX request has been

Here is a script that I created: <script type="text/javascript> $('.storage').html(""); setInterval(function(){ $.get('./playcommand.php', function(data) { if($('.storage').html() !== data){ ...

Encountered an issue when trying to generate a shader cache entry- there was an error when attempting to locate an

Today, I decided to write a basic Python script utilizing Selenium that would identify an element by its Css selector. My target? The input field on the Google webpage, specified by input[name=q] Upon running the script, Chrome opened as expected but prom ...

What is the best way to create a mobile design in Dreamweaver while utilizing the same css file as my Desktop code?

Where does my layout provide a solution, and what adjustments can be made? I attempted modifying the screen dimensions in the Dw Design page without success. ...

Having trouble with the unresponsive sticky top-bar feature in Zurb Foundation 5?

According to the information provided on this website, it is recommended to enclose the top-bar navigation within a div element that has both the class "contain-to-grid" and "sticky". However, I have noticed that while the "contain-to-grid" class exists in ...

The container is not showing the JSTree as expected

My current project in JavaScript involves integrating a JSTree structure, but I'm encountering an issue where the tree is not showing up or rendering within its specified parent container. Below is the snippet of code I have been using to attempt to d ...

Loading HTML content in Electron using the renderer process JS

During the development phase, I found that the jquery load method for loading HTML views in Electron was functioning smoothly: app.appContainer.load('html/homePage/homePage.html', () => { app.addListenerToHomePage(false) }); I have individua ...

What is the best way to show checkbox selections based on my database structure?

Two variables, one for checkboxes and the other for checked values are causing an issue in displaying them from controller to view. The code to handle this in the controller is as follows: $scope.infoParticipant = functionThatGetsParticipants(); ...

Providing input through the URL bar in PHP and HTML

I have a simple form on my website's HTML page. <form action="post.php" method="post"> Message: <input type="text" name="message" /> &nbsp; <input type="submit" name="submit" value="send"> </form> After submitti ...

Implementing the sticky positioning property to keep a div container fixed at the bottom of the page

As Bootstrap 4 no longer supports .affix, I had to look for an alternative solution to keep a box fixed. I needed a div container to remain fixed as you scroll to it. My current workaround is using: .fixedcard{ position: sticky; top:75%; } However, th ...