Resolution of HTML display

I have been exploring the @media feature on this website and attempted this:

@media screen and (max-width: 1350px;)
{
    #td6img{margin-left:400px;}
}

I believe the default resolution is 1360px, but when I adjust the window size, the image doesn't seem to budge and remains in the same position. Here is the original CSS for the image before resizing:

#td6img
{
    display:block;
    margin-left:410px;
}

The CSS doesn't appear to update when resizing. I'm not sure if I set the width too high or if there's a mistake with the @media rule.

How can I reposition the image? I want to apply this to other elements as well, not just this one.

Answer №1

Here is a demonstration of a straightforward media query:

section {
  width: 300px;
  @media (min-width:1000px) {
    width: 600px;
  }
}

In this instance, the section element will be 300px wide by default. Once the screen width hits 1000px, it will adjust to 600px. This method follows a "mobile-first" strategy where smaller screens are prioritized in the CSS.


If you have an element with the id #highlightedSection, you can modify the padding as shown below.

#highlightedSection {
  padding-top: 20px;
  @media (min-width: 1200px) {
    padding-top: 40px;
  }
}

This will alter the padding-top property once the screen size reaches

1200px</code) and above. Otherwise, the padding value will be <code>20px
.

Remember, using ids for styling should be avoided unless specifically targeting elements with Javascript; classes are generally more appropriate for styling purposes.

Answer №2

Make sure to omit the semicolon (;) from your media query

@media screen and (max-width: 1350px)
{
    #td6img{margin-left:400px;}
}

Answer №3

To start, make sure to eliminate the semicolon from your media query.

@media screen and (max-width: 1350px) {
    #td6img { margin-left: 400px; }
}

Another tip is to utilize your browser's inspector tool to check the size of your browser's viewport. Confirm that your viewport is indeed as large as 1350px. Additionally, take note that the element only shifts by 10px at that breakpoint, which might not be very noticeable.

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

The @font-face feature in IE11 encounters issues when utilized within an @media query

In my IE11 browser, I am utilizing fonts downloaded from MyFonts. When I specify them as shown below, they load without any issues: @import url("//hello.myfonts.net/count/myFId"); @font-face {font-family: 'HelveticaNeueLTStd-Lt'; src: url(&apos ...

Slide the menu off to the right

Check out these images to see my progress: Main Image. When you click on the menu, everything shifts right. I've managed to set up the push menu, toggle switch menu, and main divs. Now I need help with centering the 3 lines that are clicked within th ...

The footer lies at the bottom of the page, demarcated by

I'm struggling to position the footer at the bottom of the page with a horizontal line just above it. Despite trying various resources, I can't seem to get the footer to stay at the bottom. I'm currently using a blog template as the basis fo ...

Achieve the positioning of a Bootstrap navbar within a div without it getting wrapped by following

I have been attempting to overlay my navbar on top of a background image by nesting it within a div and using absolute positioning. However, I've run into an issue where the navbar-header/navbar-brand section causes the rest of the navbar to wrap onto ...

Perform a check on the state of the slideToggle using an if-else function and provide a report on the slideToggle state

http://jsfiddle.net/vmKVS/ I need some help understanding the functionality of slideToggle using a small example. After toggling for the first time, the options element changes color to green. However, I expected the menu element to turn red when I togg ...

Embedding CSS stylesheets in a Django template

I'm currently working on a large Django website and in the process of adding the HTML templates. Here is the file tree for the main part: C:. +---forums | | admin.py etc | | | +---migrations | | | ... | | | +---templa ...

Preserve the original position of the inner <div> when animating the container <div> using JQuery

I am currently working on a small website and encountering some challenges with jQuery animation. My issue involves placing a single character text inside a circle and wanting it to grow when the user hovers over it, while keeping the inner text in its ori ...

The issue arises when attempting to apply CSS styles to an existing component or body tag,

I am currently working on an Angular 7 project where I have a requirement to dynamically load a component using routes. However, when I try to add styles for the body tag and existing component tags in the dynamically loaded component style-sheet, they do ...

Python regular expression problem with matching regex

Hey there, I'm diving into my first question on stackoverflow and I've been struggling with it for hours. I'm sure the solution is right in front of me, but I just can't seem to find it. My goal is to extract information from a webpage ...

Transitioning a static div within a CSS grid to fill the entire screen

I have created several blocks within a CSS grid layout structured as shown: $('.box').click(function(){ $(this).toggleClass("active"); }); .grid-container { display: grid; grid-template-columns: repeat(14, 1fr); grid-template-rows: r ...

Inverting the hierarchy of a tree structure

I am currently working with a tree structure and utilizing the jstree jQuery plugin. My main objective is to reverse the structure. https://i.sstatic.net/PG1Ha.png The desired structure should resemble the one shown in this image. I have made modificatio ...

What is the best way to showcase a value in JavaScript using CSS styling?

I'm looking to customize the background, font style, and outline for both open and closed elements in the code snippet below: a.innerHTML = "We are Open now now."; a.innerHTML = "We are Closed, arm."; Additionally, I want to appl ...

Create a focal point by placing an image in the center of a frame

How can an image be placed and styled within a div of arbitrary aspect ratio to ensure it is inscribed and centered, while maintaining its position when the frame is scaled? Ensure the image is both inscribed and centered Set dimensions and position usin ...

Concealing a hyperlink within a DIV by removing or hiding it

I am looking to temporarily hide or remove a specific link (team.aspx) within a drop-down menu, with the intention of adding it back in later. Here is my current code: <div id="nav_menu"> <ul id="nav"> <li class="current"><a href= ...

Prevent scale animation for a specific section of the icon using CSS

I need help in preventing the scale animation of the :before part of the icon class from occurring when the button is hovered. The current behavior is causing the arrow to look distorted on hover... Link to the code on Codepen HTML <div class="se ...

What is the role of z-index in relation to floating elements?

Why is it impossible to assign a z-index to a floated image and what are the reasons behind this limitation? ...

Customizing div elements in various RMarkdown documents with a CSS file

I want to apply styling to divs in various RMarkdown files using a CSS file. However, I am encountering syntax issues when trying to use the external CSS file to style the div. Embedding the style tag within the rmarkdown body works as shown below: --- ti ...

Creating a personalized music player using an audio tag with HTML, CSS, and JavaScript

I am currently working on developing a unique music player from scratch without utilizing the "controls" tag within the audio element. My goal is to build something akin to the SCM Music Player. I've chosen not to use the SCM-provided player due to it ...

Refreshing the database with new information from an HTML table

Presented below is a table structure: <table id="skuTable" role="grid"> <thead> <th class="skuRow">Order</th> <th class="skuRow">Machine</th> <th>Fab. Date</th> <th cl ...

Position card action buttons at the bottom using Material UI

I have been working on an app using ReactJS and incorporating MaterialUI (for React) along with React Flexbox. One issue I've encountered is the struggle to position the card buttons at the bottom, which seems to be a common problem across different ...