logo
down
shadow

Absolute and relative positioning involving media queries?


Absolute and relative positioning involving media queries?

Content Index :

Absolute and relative positioning involving media queries?
Tag : html , By : Guyou
Date : November 29 2020, 09:01 AM

To fix this issue Here you go: http://codepen.io/n3ptun3/pen/avrXaE?editors=110
To complete this, I positioned the #navbar relative to its normal position. Then I absolutely positioned the #logo and #container (from their first positioned ancestor element, i.e. #navbar.)
<div id="page">
  <div id="navbar">
    <div id="logo"></div>
    <ul id="container">
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
      <li><a href="#">Media</a></li>
    </ul>
  </div>
</div>
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700);

body {
  background: #f3f3f3;
  font-family: 'Open Sans', sans-serif;
  margin: 0 auto;
}

#page {
  height: 600px;
}

#navbar {
  position: relative;
  width: 100%;
  height: 50px;
  top: 75px;
  background-color: #fefefe;
}

#logo {
  width: 150px;
  height: 150px;
  border-radius: 75px;
  background-color: #333;
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translate(-50%);
}

#container {
  position: absolute;
  top: 13px;
  padding: 0;
  margin: 0;
  width: 100%;
}

#navbar li {
  display: none;
}

#navbar li a {
  color: #333333;
  text-decoration: none;
  font-size: 0.75em;
  font-weight: bold;
  text-transform: uppercase;
}

#navbar li:nth-child(3) a, 
#navbar li:nth-child(4) a {
  position: relative;
  left: 100%;
}

@media only screen and (min-width: 569px) {
  #navbar li {
    display: inline-block;
    list-style: none;
    width: 20%;
    float: left;
    text-align: center;
  }
}

@media only screen and (min-width: 769px) {
  #logo {
    left: 50px;
    transform: translate(0);
  }

  #container {
    width: 30%;
    right: 50px;
  }

  #navbar li {
    width: 25%;
  }

  #navbar li:nth-child(3) a, 
  #navbar li:nth-child(4) a {
    left: 0;
  }
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Relative positioning + Absolute positioning VS Floats Left an Float Right (Which approach do you use in your CSS)?


Tag : css , By : Morbo
Date : March 29 2020, 07:55 AM
this one helps. I my experience using absolute positioning works well on elements you are in 100% control of in terms of size; like a logo, a meny, rss links and things like this. Then you can place these elements exactly where you want them.
I prefer using float when I am displaying dynamic content on a page, since the size of the element can change, and the placement of all elements in relation works really good with floats. Just remember to clear the floats when needed!

Positioning absolute inside list with positioning relative for jQuery animation


Tag : css , By : Tom D
Date : March 29 2020, 07:55 AM
it should still fix some issue When you apply positioning to an element, it will use the positioning available on it's parents. If none is provided, it will position to the body element. So when you position: absolute to get the text/link at the bottom of the element, you have to position: relative (or position: absolute) one of it's parents, otherwise it won't know which you want it to position in relation to. Conversely, whichever it finds first, it will use that element to position against.
I think it's possible you've got too much markup to accomplish what you're doing here (what is the .placeholder for? why not just use the li?), and the spans that wrap one of the blocks looks out of place (and should be a div if you really need a wrapper there). And I'm not sure, but you might want to change #items to a class, if you need to reuse it. It looks out of place as an id. And your id and class names are not descriptive, and your selectors are not specific enough (generally, stay away from ul and li for styling specific parts of a page, as these have a global effect).
<li>
    <div class="itemplaceholder">
        <img src="http://www.els.qut.edu.au/blendedlearning/blackboard/graphics/test_on.gif"/>
        <p>
            Test title<br/>
            Description A
            <a href="#">Link</a>
        </p>
    </div>
</li>
#items {
    display: inline;
    position:relative;
    margin: 0;
    padding: 0;
}
#items li {
    float: left;
    list-style-type: none;
    margin: 0;
    padding: 5px 0 0 0;
}
#items .itemplaceholder {
    height:200px;
    width:160px;
    text-align: center;
    position: relative;
}
.placeholder {
    width:640px;
    height:200px;
    overflow: hidden;
}
.content {
    width:800px;
    height:240px;
}
#items .itemplaceholder p {
    position: absolute;
    bottom: 5px;
    width: 100%;
    height: 50%;
}
#items .itemplaceholder p a {
    position: absolute;
    display: block;
    bottom: 0;
    text-align: center;
    width: 100%;
}

stop menu from getting untidy when changing from relative positioning to absolute positioning


Tag : asp.net , By : B3CFT
Date : March 29 2020, 07:55 AM
should help you out First off, there's a bit of html fixup needed. ( an extra double quote, a badly closed
element, but ... well ... perhaps, instead of restructuring your whole thing to avoid the extra white-space at the bottom, you could just add
#holder {
    overflow: hidden;
}

Absolute Positioning with Media Queries


Tag : html , By : besn
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I am having trouble styling an absolute element using media queries. Right now I have a box that is positioned at the top left-hand corner of the screen. But, when the screen size is below 768px, I want this box to stick to the upper right-hand corner. Here's my code: , Try this:
@media (max-width: 768px) {
  div {
    right: 0;
    left: auto;
  }
}

Absolute Positioning and Media Queries


Tag : css , By : Patastroph
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • how to fix link tag in html after changing css
  • How do I add a top padding to the second row?
  • Is it possible to split XML into multiple HTML pages with page navigation?
  • AngularJS: responsive height in bootstrap
  • Hide second line of text with CSS
  • repeating-linear-gradient not working in Edge browser and internet Explorer Browser
  • how to make search and form category merges like amazon on bootstrap
  • Bootstrap: Rearranging rows into columns and changing the order of elements
  • How can I move a label under a text box?
  • How save LinearGradient To database
  • How to reposition an image with a linear gradient using css?
  • HTML audio will not play when page opened by batch file
  • CSS Three Tone Diagonal Background
  • How to use slots inside of template components in HTML
  • Using span tags in meta description & title, for dual languages
  • How to make an icon/span selectable by pressing Tab key?
  • Add dynamic margins using UI Kit
  • Add margin-top to textbox
  • What is the correct semantic HTML markup for a title (book, movie, etc.), according to the spec? Is it an <em> tag
  • How to make an animation in Geoserver or in Leaflet
  • Buttons overlapping when shrinking window
  • Stretch an element to the end of the automatically calculated grid, not just the explicit grid
  • What relation is there between Angular's <ng-content> and ShadowDOM
  • CSS background for div element is not working
  • CSS Marquee: multiple paragraphs overlaps
  • I want to align search bar to extreme right
  • Getting blank white space to the left of content inside pre tags
  • My viewer.html won't load any css and jss files
  • How to apply multiple styles to HTML to only part of a title?
  • Want to make text div transparent on a parallax area
  • Is there a way to make this ID plus descendants CSS rule less specific?
  • Is there a way to drop in a stylesheet to get a Material theme or similar for all form elements on the page?
  • How do I make a sideways L look in html/css?
  • Why won't the color #e67d22e1 display in Safari?
  • How to select specific tag's attribute value with xPath?
  • How to make div rows fill available height
  • How to fix text inside a block that grows
  • svg hexagon halftone pattern
  • How to edit a website's element's background colors using a chromium extention
  • What is the main tag in HTML5 ? How does it differ from body tag?
  • My image is flowing out from my div column. How I can fix it and made the image full-size into div
  • How to draw line in react
  • Why Transition css is not working in child selector css
  • How to modify materialize css select option?
  • How to center some text in a rectangle in CSS?
  • How do I equally space out css grid columns?
  • How to make sure all the parts of a macro are running correctly?
  • How to adjust the zoom of website at different browser at different screen size?
  • Can't set max height on child div properly
  • Why background color is not applying to DIV container?
  • Need to select the first-child
  • No space between attributes in buttons
  • How can I block google from crawling my page, but still let Baidu do it?
  • Rendering html content in matToolTip (Angular)
  • Embedding an iframe when iframe height is variable
  • How to use 'word-break: break-word' with link inside of text?
  • How I can animate circular progress bar from left to right?
  • Angular 6 - How can I hide a div onclick of outside of that div
  • How to fill an inline-block div with a solid color?
  • Form file doesn't align with rest of form
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com