What is the best way to code the page without using javascript?
Both of the HTML elements (div1, div2) need to have a fixed size.
What is the best way to code the page without using javascript?
Both of the HTML elements (div1, div2) need to have a fixed size.
To achieve the desired layout, you must utilize CSS attributes such as
position
,
top
,
bottom
,
left
,
right
, and
height
.
For example:
<div style="position:absolute; left:0; right:0; top:0; bottom:0">
<div style="position:absolute; left:0; right:0; top:0; height:42px; background:green">div1</div>
<div style="position:absolute; left:0; right:0; bottom:0; top:42px; background:red">div2</div>
</div>
position:absolute
allows you to specify layout in pixels and percent.left:0; right:0
ensures full-width.top:0
aligns a div to the upper edge.bottom:0
aligns a div to the lower edge.height:42px
and top:42px
define the tiled layout.View a vertical layout example:
<div style="position:absolute; left:0; right:0; top:0; bottom:0">
<div style="position:absolute; top:0; bottom:0; left:0; width:42px; background:green">d i v 1</div>
<div style="position:absolute; top:0; bottom:0; right:0; left:42px; background:red">d i v 2</div>
</div>
See an example with four tiles:
<div style="position:absolute; left:0; right:0; top:0; bottom:0">
<div style="position:absolute; top:0; height:80px; left:0; width:42px; background:green">d i v 1</div>
<div style="position:absolute; top:0; height:80px; right:0; left:42px; background:red">d i v 2</div>
<div style="position:absolute; top:80px; bottom:0; left:0; width:42px; background:red">d i v 3</div>
<div style="position:absolute; top:80px; bottom:0; right:0; left:42px; background:green">d i v 4</div>
</div>
It's important to note how top
+height
and left
+width
cooperate together.
Additional tiles can be added by incrementing the top position by the previous tile's height.
Using overflow
, you can specify the behavior for excessive content. overflow:auto
adds a scrollbar if necessary, while overflow:hidden
would crop it.
Although I have yet to experiment with a design setup similar to the one you described, you might want to consider exploring the method suggested in this resource that discusses negative margins.
I'm facing a challenge in creating a responsive webpage with multiple divs. Here is the structure I am trying to achieve: <div id="container"> maximum width of 1200 and height of 1000 <div id="vertically-static-top">20 pixels high< ...
I'm having trouble switching between a CSS column layout and a normal layout for a div element with the ID 'article'. The jQuery script I wrote doesn't seem to work properly, as the entire thing disappears. Can anyone advise me on how t ...
The ProjectsSection component is responsible for rendering a document section with a header and cards. The goal is to trigger a header animation only when the header becomes visible on the screen for the first time and have it run once. However, adding a s ...
As a newcomer to EXT JS, I am exploring the use of MVC in my projects. Consider a scenario where I have a web service with a flexible data model. I would like to dynamically create models, stores, and components based on the data from these stores. Let&a ...
I am having an issue where the code is not sending data to the database after clicking on submit. I have also attempted using the POST method with no success. These are the table names in my database: id (AI), image, name, dob, fathername, fatheroccu ...
Is it possible for my aside element and div.content to evenly split the available space in the container? Additionally, should the grid within div.content take up all the vertical space? The issue I'm encountering is that grid items aren't able ...
I have set up a basic bottle server using Python: from bottle import route, run, static_file @route('/') def home(): return static_file("home.html", root='.') @route("/<fileName>") def respond(fileName): return static_f ...
Incorporating keyboard shortcuts into my HTML + GWT application is a goal of mine, but I am hesitant about triggering actions when users are typing in a text area or utilizing the keyboard for select menu operations. I am curious if there exists a method ...
I've created a unique set of visually appealing cards that house meaningful messages within an infinite scrolling feed. The intended functionality is for the complete message to be displayed upon clicking a "more" button, as the messages are typically ...
I've encountered an issue with my navbar where none of the specified colors are being displayed. The code snippet for the navbar is as follows: Codes: 'use client' import Head from 'next/head'; import Link from 'next/link&apo ...
How can a specific item in the localStorage be cleared using javascript within an html file? localStorage.setItem("one"); localStorage.setItem("two"); //What is the method to clear only "one" ...
Rumors have it that Bootstrap 4 will make its debut during the year 2016. When duty calls for an upgrade, is a complete re-write truly the best solution? Tackling such a project from Boostrap 2 to 3 was no small feat, and I find myself hesitant to take on ...
I have come across some solutions, but I am struggling to incorporate them into my code as some require elements that are not compatible with my project. Let's get to the question: I need help making an existing CSS drop-down menu accessible for key ...
Is it possible to address all IE bugs by writing CSS in just one conditional block? <!--[if lt IE 9]> <link href="ie.css" rel="stylesheet" type="text/css" /> <![endif]--> If I use a single conditional comment for IE versions less th ...
With pure HTML/CSS, I can achieve the following: <div color="red"> red </div> <div color="yellow"> yellow </div> div[color="red"] { color: red; } div[color="yellow"] { color: yellow; ...
Is there a method to stop users from inputting scripts into text fields or text areas? function filter($event) { var regex = /[^a-zA-Z0-9_]/; let match = regex.exec($event.target.value); console.log(match); if (match) { $event.pre ...
Hey there, I'm a newbie trying my hand at DOM creation. I've encountered a strange issue with appendChild - the first and second tries work fine, but I'm completely stuck on the third attempt. Here's my HTML: <html> <head> ...
I developed a custom jQuery plugin that replaces the default scrollbar with my own, managing mousewheel and bar dragging events. The issue arises when I place content containing my custom scrollbar within another content also using my scrollbar. When I sc ...
Encountering a browser support issue at the moment. Everything is functioning as expected on Firefox and Chrome, but Safari is causing problems with images. Currently, the image size is set using "object-fit: cover" and working properly on Chrome/Firefox. ...
My goal is to use jQuery to scroll the page to a specific div when a button is clicked. Despite not seeing any errors in the JavaScript console, the page does not actually scroll to the desired location. I have tried placing the jQuery js file before and a ...