Float a Div in Top Right Corner Without Overlapping Sibling Header

Float a div in top right corner without overlapping sibling header

If you can change the order of the elements, floating will work.

section {  position: relative;  width: 50%;  border: 1px solid;}h1 {  display: inline;}div {  float: right;}
<section>  <div>    <button>button</button>  </div>
<h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1></section>

how to take the header and paragraph in separate line when the header is float right?

You can use text-align property for this.
The text-align property specifies the horizontal alignment of text in an element.

div.a {
text-align: center;
}

div.b {
text-align: left;
}

div.c {
text-align: right;
}

div.c {
text-align: justify;
}

And you can try more about text-align property using this link.
https://www.w3schools.com/cssref/playit.asp?filename=playcss_text-align

Is this your expected result???

<!DOCTYPE html>
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Bree+Serif&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="stylesheet.css">

<style>
.aboutus{
height: 100vh;
width: 100%;
}
.details{

}
.details h1{
text-align: right;
text-transform: uppercase;
color: #EE4036;
font-size: 4.5em;
font-weight: bold;
}
</style>
</head>

<body>

<section class="row aboutus">
<div class="container">
<div class="details">
<h1>about us</h1>
<p>some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.some text here.
</p>
</div>
</div>
</section>
</body>
</html>

CSS - position div on top right corner of a table

You need to copy all of your elements in this type of questions, however to give you a general sense whenever you have a display block component such as div, it takes the whole horizontal space that is available.

So to move an i or span which are inline elements you can just do text-align: right:

Here is an example:

div {  background: grey;  text-align: right;  padding: 1rem;}div span {  font-size: 3rem;}
<div>  <span>☺</span></div>

Why the div not coming on next line when float the ul to right?

Put clear: both (or right) to div.

div {clear: both}

https://jsfiddle.net/4kd4y2zz/1/

Float right is not affecting the layout of my navbar

Floats really aren't the best way to do this anymore. Try flexbox!

* {
margin: none;
padding: none;
box-sizing: border-box;
}

header {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}

header nav {
display: flex;
}

header nav p {
margin: 0 10px;
}
<header>
<h1 class="logo">Learn to code</h1>
<nav>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</nav>
</header>

How to prevent fixed positioned element overlapping others elements in css?

1:

By adding margin-left you can make sure that long fixed div doesn't overlap the others.

#two, #three {
margin-left:20%;
width:80%;
height:500px;
}

2:

Adding the bottom:0px; makes it the height of the window because it expands from the top to the bottom.

#one {    
position:fixed;
top:0px;
bottom:0px;
left:0px;
width:20%;
}

Note: I also added a flexible width of 20% to the #one div so that it plays nicely with the other two flexible width divs.

Fiddle: http://jsfiddle.net/ZPRLd/

How to overlay one div over another div

#container {  width: 100px;  height: 100px;  position: relative;}#navi,#infoi {  width: 100%;  height: 100%;  position: absolute;  top: 0;  left: 0;}#infoi {  z-index: 10;}
<div id="container">  <div id="navi">a</div>  <div id="infoi">    <img src="https://appharbor.com/assets/images/stackoverflow-logo.png" height="20" width="32" />b  </div></div>


Related Topics



Leave a reply



Submit