Images positioned in the middle of two different parts of a webpage

My journey into HTML CSS involves creating a basic website that caught my eye, with the goal of positioning an image between two sections.

In this example, we see the image lying between two sections.

I'm curious to understand more about this particular design style. What is it called?

Answer №1

If you want to easily position the tree, just make sure to set its position as "relative".

For more information on the position property in CSS, check out this link.

To create 2 separate sections, I made use of a div tag:

#div1 {
  background-color: red;
  width: 800px;
  height: 200px;
  display: block;
}

#div2 {
  background-color: yellow;
  width: 800px;
  height: 200px;
  display: block;
}

#myImg {
  height : 200px;
  position: relative;
  top: -50%;
}
<div id="div1">

</div>

<div id="div2">

 <img id="myImg" src="https://banner2.kisspng.com/20180206/age/kisspng-tree-magnolia-christmas-nature-transparent-background-5a7a720d01efd2.8244164415179740290079.jpg" alt="" />
</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

I am attempting to design a working Hamburger icon using HTML and CSS, but it is not collapsing as intended

I am new to Bootstrap and experimenting with it. The responsive navbar in Bootstrap is not functioning as expected on my screen. Can someone help me identify the issue and fix it? <!DOCTYPE html> <html> <head> <link rel=&q ...

The image is not displaying on the button

When using 3 buttons in my extjs script, I noticed a strange issue where the buttons were not visible on the page. Upon inspecting the elements using firebug, here is what I found: <button id="button-1051-btnEl" class="x-btn-center" autocomplete="off" ...

The placeholder string is being accepted as the input value for the number

My issue is with a form input of type number. When the form is submitted without entering any number, it treats the placeholder text "rating" as the value. How can I stop this from happening? I need to make sure that the input number field is marked as in ...

Steps to retrieve specific text or table cell data upon button click

Greetings, I am a beginner in the world of html and javascript, so please bear with me :) My challenge involves working with a table in html. Each row contains a dropdown menu (with identical options) and a button. When the button is clicked, I aim to sen ...

Generate a table inside a bootbox dialog using the data retrieved from an ajax call

I'm currently working on an app that requires attendance to be reported for specific events. I retrieve a list of JSON objects using AJAX. My goal is to create a table within a bootbox dialog that generates new rows for each item in the result from m ...

"Exploring the variations in design between wordpress.com and self-hosted wordpress

I'm currently puzzling over the source of the disparities in style between my Wordpress site hosted elsewhere and my identical theme on Wordpress.com. It's perplexing to see such contrasting appearances while I migrate my blog. After some irrele ...

PHP Generating random numbers

After stumbling upon this code online, I have a couple of questions: <? $seed = floor(time()/(60*5)); srand($seed); $item = rand(0,9); echo $item; ?> How can I modify this code to generate random numbers to the tenth place, such as 5.56, rather tha ...

The search functionality on my website, powered by webapp2 and HTML, is not functioning properly

Upon examination, I noticed that my search term is being transmitted to my handler as an empty string. Here are the key components: This is my HTML form: <form class="navbar-search" action="/search"> <input type="text" class="se ...

What is the best way to hide the jQuery modal I created?

Hello everyone! Currently, I am working on coding a simple JS modal that can be opened and closed smoothly. The issue I am facing is related to adding a click function to (.black-overlay) in order to fade out everything and close the modal. <div class ...

Set tab navigation widget with a fixed height

I am struggling with setting a fixed height for my tabs widget so that when I add more content, it will display a scrollbar instead of expanding endlessly. I have checked the CSS and JS files but cannot figure it out. It is important for me to contain this ...

Switching Classes with a Click of a Button

Hey there, I'm currently using this menu: spoilers.tumblr.com/tvschedule, and I have a script below. The functionality works well with the click event, but I'm having some trouble with the hovering effect. To make certain classes visible on hover ...

Learn the steps to create a vertically tiled background using a clipped image

My goal is to create a vertically tiled background by clipping the top 50px of a background image and using only that portion. However, the code I have below isn't working as expected. Even though I've given a higher z-index to the <div class= ...

The accordion's height will expand on its own when one of the accordions in the same row is

Whenever an accordion expands in the same row in MUI, the height of the accordion will automatically increase. See below for the code snippet: {[1,2,3,4,5].map((i)=> <Accordion style={{backgroundColor: '#F9F9F9&ap ...

Making an Ajax request using the identical ID

My current approach involves utilizing an ajax call to achieve the following: Each time a link is clicked, it generates a new link at the bottom with the same text. HTML : <nav class="navbar"> <ul> <li> ...

What steps should I take to address this bug in my Django HTML template?

I've encountered a strange bug with Django HTML templates where everything appears to be placed within the body tag, regardless of my efforts. There is also some invisible text that throws off the page alignment. Here is how my browser displays the S ...

Having trouble with your JQuery code?

I created this program to toggle the visibility of a message on a webpage. The hiding and unhiding functionality is working, but I am encountering an issue when trying to change the text on the button. Here is the HTML Code: <!DOCTYPE html> < ...

Issues arise in mobile Safari when attempting to load JavaScript files, resulting in

Encountering an issue with my Angular app on mobile Safari during the initial load, where it hangs on a blank page for nearly 2 minutes. Interestingly, the app functions perfectly on other browsers, including Mac Safari and iPad Safari. Initially, I suspe ...

CSS that allows elements to float both to the right and left with independent sizes

Attempting to achieve left and right floating that is independent of height... Take a look at my example. In this example, 2 and 4 appear to have a space between them. Unsure of the best way to implement this without encountering issues in different brows ...

placement of facebook and twitter plugins

I am curious to know if there would be any issue if I were to utilize these two scripts on the same page: <a class="twitter-timeline" width="200" height="440" href="https://twitter.com/smth" data-widget-id="347786415695880192"></a> <script ...

How to style a sublevel menu to appear next to its parent using CSS

I have a menu that is currently functioning well, but I would like to add a new sublevel onto it. However, if I directly add the new options, they end up hiding the existing ones on the menu. Here's an image for reference: I want the new options to ...