Crafting a website in HTML

Hello there! I am looking to create a flexible HTML and CSS page that adjusts in size when the user resizes the browser window. I want the page to be responsive to different resolutions. I've explored various solutions on this platform, but unfortunately, none of them seem to work for me. I have also experimented with media queries.

Below is my current CSS and HTML code:

* {
margin: 0;
padding: 0;
}
body{
font-family: 'Francois One', Arial, Helvetica, sans-serif;
color: white;
text-align:center;
background:black;

}
.corpo{
margin-top: 5px;
margin-left:  400px;
margin-right: 250px;
float:middle;

}
header{
margin: 40px 0;
}
.menu li{
display: block;
float: left;
width: 125px;
height: 50px;
line-height: 50px;
text-align: center;
color: #2C3E50;
border-right: 1px solid #2C3E50;
background: -webkit-linear-gradient(top, #FFFF00 50%, #FFFF00 51%, #f6f6f6 100%);
background: -moz-linear-gradient(top, #FFFF00 50%, #FFFF00 51%, #f6f6f6 100%);
background: -o-linear-gradient(top, #FFFF00 50%, #FFFF00 51%, #f6f6f6 100%);
background: -ms-linear-gradient(top, #FFFF00 50%, #FFFF00 51%, #f6f6f6 100%);
border-color:black;
opacity:1;
position:relative;
}
.menu li:hover{
cursor: pointer;
background: -webkit-radial-gradient(center, ellipse cover, #ffffff 0%, #e5e5e5 100%);
background: -moz-radial-gradient(center, ellipse cover, #ffffff 0%, #e5e5e5 100%);
background: -o-radial-gradient(center, ellipse cover, #ffffff 0%, #e5e5e5 100%);
background: -ms-radial-gradient(center, ellipse cover, #ffffff 0%, #e5e5e5 100%);
color: slateGrey;
border-color:black;
position:relative;
}
.primo{
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.ultimo{
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.sub-menu{
visibility: hidden;
}
.menu li:hover .sub-menu{
visibility: visible;
}
.sub-menu li{
border-top: 1px dotted #2C3E50;
}
.sub-menu li:hover{
width: 145px;
background: -webkit-radial-gradient(center, ellipse cover, #f7fbfc 10%, #add9e4 100%);
background: -moz-radial-gradient(center, ellipse cover, #f7fbfc 10%, #add9e4 100%);
background: -o-radial-gradient(center, ellipse cover, #f7fbfc 10%, #add9e4 100%);
background: -ms-radial-gradient(center, ellipse cover, #f7fbfc 10%, #add9e4 100%);
transition: all 0.1s ease 0s;
-webkit-transition: all 0.1s ease 0s;
-moz-transition: all 0.1s ease 0s;
-o-transition: all 0.1s ease 0s;
-ms-transition: all 0.1s ease 0s;
}
.ultimo-sub{
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}

.menu li a:link{
color:black;
text-decoration:none;
}

.menu li a:hover{
color:black;
text-decoration:none;
}

.menu li a:active{
color:black;
text-decoration:none;
}

.menu li a:visited{
color:black;
text-decoration:none;
}

p{
color: #FFFF00;
margin: 0px 380px 0px 400px;
font-size:150%;
text-shadow: 2px 0 0 #000, 0 -1px 0 #000, 0 2px 0 #000, -1px 0 0 #000;               //text-shadow: 2px 0 0 #000, 0 -1px 0 #000, 0 2px 0 #000, -1px 0 0 #000;

}

Answer №1

Ensure to include the viewport meta tag in your code.


<meta name="viewport" content="width=device-width, initial-scale=1">

Implement media queries for responsiveness. You can refer to the following link for more information: http://www.example.com/css/responsive-design-media-queries

Answer №2

Don't forget to include this snippet in your CSS file:

/*
  This CSS code is based on the following resources:
  1. http://stephen.io/mediaqueries
  2. https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
*/

/* Add media queries for targeting specific devices */
@media only screen 
and (min-device-width : 375px) 
and (max-device-width : 667px) {
  
}

/* Customize styles for iPhone 6 portrait and landscape mode */
@media only screen 
and (orientation : landscape) {
  
}

@media only screen 
and (orientation : portrait) {
  
}

/* Create responsive design for iPhone 6 Plus */
@media only screen 
and (min-device-width : 414px) 
and (max-device-width : 736px) {

}

@media only screen 
and (orientation : landscape) {
  
}

@media only screen 
and (orientation : portrait) {
  
}

/* Specify media queries for various iPhone models */
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 568px) {

}

...

/* Define media queries for different tablets */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 2) {
  
}

...

/* Target specific watches with media queries */
@media
  (max-device-width: 42mm)
  and (min-device-width: 38mm) { 

}

@media 
  (max-device-width: 218px)
  and (max-device-height: 281px) { 

}

Answer №3

Don't forget to include the viewport tag in your HTML code:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

It is recommended to utilize a responsive front-end Framework like Bootstrap or Foundation to ensure that your website displays correctly on all devices.

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

Start the CSS3 animation in reverse right away

I am trying to achieve a "flashing" effect by adding the .shown class to my #overlay, causing the opacity to fade in for 2 seconds and then immediately reverse, fading out for another 2 seconds. After experimenting with removing the class, I found that it ...

Tips for accessing values from a bs4 result set in Beautiful Soup?

Is there a way to extract all the title values from this bs4 result set? [<span class="zaman" title="16.3.2022 15:22:44">1 hf.</span>, <span class="hide zaman pull-right ml-5 mt--1">( Message Deleted )</sp ...

Using mix-blend-mode with an SVG image within a colored <div>: tips for applying it to the background color of your HTML

I am facing an issue with a SVG file that has mix-blend-mode styles defined on certain elements. The blending is working properly for the elements inside the SVG, but not for the background color of the HTML <div>. For instance: <!doctype html> ...

The function mysql_fetch_assoc is displaying absolutely nothing (neither null, nor 0, nor an empty string)

I'm encountering an issue with retrieving data from my $result variable. Everything works smoothly when there is one result, but if I try to check for a result and find none, the $array ends up empty. Running both commands below results in nothing bei ...

What's the best way to align a bottom navigation bar in the center?

Hey there! I recently added a bottom navigation bar to my website using HTML and CSS code. However, I'm having trouble centering it at the bottom of the page. Any suggestions or solutions would be greatly appreciated. Attached are screenshots of the H ...

Display the background-image of the <body> element only when the image has finished loading

I have a webpage where I want to delay showing a large image until it has finished downloading. Instead, I would like to display a background with a fading effect while the image loads. The challenge is that the background image must be set within the bod ...

Is there a way to emphasize a particular day on the calendar obtained from the URL?

I have implemented FullCalendar functionality to enable users to select a specific date, retrieve data from a database, and then reload the page with that data. The page is updated with the selected date in the URL. However, when the page reloads, althoug ...

Clicking on the images will display full page versions

Apologies for not making an attempt just yet, but I'm struggling to locate what I need. Here's the menu structure in question: <div class="overlay-navigation"> <nav role="navigation"> <ul class="test"> & ...

Windows Outlook - automatic tag wrapping feature

My goal is to ensure that buttons wrap properly inside their cell. I have set a max-width for the cell as well as a ghost table of 200px. The width should not extend past 200px, causing the span to wrap to the second row automatically. This method works ev ...

Ways to eliminate a css class with jquery based on a specific screen dimension

There is a div element that includes a specific class. My goal is to remove this class when the window is resized to fit a mobile view-port. <div class="box"></div> ...

A step-by-step guide on incorporating box-shadow for the jackColor in the Switchery Plugin

I am looking to add a box shadow to my iOS7 style switches for checkboxes when they are checked. Here is the code I have so far: var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch')); elems.forEach(function (html) { va ...

Materialize CSS is throwing an error: 'velocity is not a function'

Encountering an issue with Materialize CSS. A JavaScript error appears 'I('.velocity is not a function', for certain actions. For instance, clicking the collapse icon on the sidenav results in e.velocity is not a function error. Similarly, u ...

Issue with Img Srcset Attribute Ignoring Smaller Images

The <img> element's srcset attribute seems to always select the larger <img> source, even when the size media query is false. I found success in using a <picture> element to ensure image selection based on browser width. Based on th ...

Unable to adjust dimensions with CSS width and height properties

I'm currently working on developing an online game with a login screen inspired by Paper.io. I have created the username input and play button, but there seems to be an issue with the width and height specified in the CSS file for the input field. Eve ...

Selecting the correct data type for react-icons

I'm currently working on designing a navigation bar with a customized type to utilize the map() function. My goal is to display an icon for each entity, so that the icon appears in front of the text within the navbar. However, I am encountering diffic ...

Comparison of Foundation5 source ordering: main content versus sidebar

I recently set up a layout with three columns using ZURB Foundation 5. The two sidebars are on the left and right, while the main content area is in the middle. While trying to follow the source ordering instructions in the documentation, I encountered so ...

Eliminate certain inline styles using jQuery

I am facing an issue with an asp menu I am using. It is automatically inserting style="width:3px;" into my menu table tds, creating an unsightly gap between my tabs. Instead of asking our developer to customize the menu just to fix this cosmetic flaw, I am ...

I am looking for an image search API that supports JSONP so that users can easily search for images on my website

I am currently in the process of creating a blog platform. My goal is to allow users to input keywords on my site and search for images directly within the website. This way, I can easily retrieve the URL of the desired image. ...

Tips for emphasizing the current element without disrupting existing styles

Is there a way to highlight an element with a border without causing it to shift? The script seems a bit glitchy when detecting mouse leaving the area. I'm unable to override parent element properties like border or outline. I also can't use pse ...

Lengthen the space between each item on the list to enhance readability

Is there a way to adjust the line height between li tags? I attempted using height:100%, but it seems ineffective. Are my methods correct? Can anyone provide guidance? The following is the code snippet in question: <html xmlns="http://www.w3.org/1999 ...