How can I center image floating in center of top page? [duplicate] - html

This question already has answers here:
How can I horizontally center an element?
(133 answers)
How do I center floated elements?
(12 answers)
Center image using text-align center?
(28 answers)
Closed 6 months ago.
I'm trying to center an image in the center of my page and fixed on top but I can't, now I have this: link for image with this code:
<body>
<header>
<img class="lustre" src="/img/lustre-inicio.png" alt="" />
...
and this CSS:
header > img.lustre {
float: left;
height: 400px;
display: flex;
}
I need to do this with the image: link for image how can I do this?

Related

centering a button responsively [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
How can I vertically center a div element for all browsers using CSS?
(48 answers)
Closed 4 months ago.
this is my first time here. I am trying to center a button exactly in the middle of the page (both vertically and horizontally) responsively. Including responsiveness to zooming(+/-) and resizing the page.
I just can't get it to be responsively in the center. Any advice or help would be appreciated!
My code so far:
<style>
.btn{
text-align: center;
margin: auto;
}
.button{
text-align: right;
}
</style>
<html>
<body>
<div class="btn">
<button class="button">hello</button>
</div>
</body>
</html>

Vertically center both Icon and span in a div [duplicate]

This question already has answers here:
How can I vertically align elements in a div?
(28 answers)
Flexbox: center horizontally and vertically
(14 answers)
Vertically align text next to an image?
(26 answers)
How to center text vertically with a large font-awesome icon?
(15 answers)
Closed 3 years ago.
The structure is like this:
css
.toolBarHolder {
height: 42px;
line-height: 42px;
}
<div class='toolBarHolder'>
<icon class='toolBarIcon'>near_me</icon>
<span class='toolBarText'>lake area</span>
</div>
with this the span can be vertically centered, but the icon failed.
Just give the properties display:flex; align-items:center; justify-content:center; to .toolBarHolder. There's no need to use line-height;
It would be like this:
css
.toolBarHolder {
height: 42px;
display:flex;
align-items:center;
justify-content:center;
}
P.D.: Since we're using justify-content: center, you will also have to set a width (div content is centered horizontally aswell).

Vertical align content with unknown height [duplicate]

This question already has answers here:
Make a div fill the height of the remaining screen space
(41 answers)
Flexbox: center horizontally and vertically
(14 answers)
How do I vertically center text with CSS? [duplicate]
(37 answers)
How can I vertically align elements in a div?
(28 answers)
Vertically centering a div inside another div [duplicate]
(24 answers)
Closed 4 years ago.
Currently I have something like the following:
<div class="wrapper">
<div id="imageWrapper">
<img src="https://picsum.photos/200/300?image=0" alt="" width="100%">
</div>
<div class="contentWrapper">
<div class="title">
sample
</div>
<div class="summary">
sample
</div>
</div>
</div>
and css:
.wrapper {
border: 1px solid;
height: 600px; //This is for test purposes and will be 100% of available height in flexbox grid
text-align: center;
justify-content:center;
}
.contentWrapper {
display: flex;
align-items: center;
flex-direction: column;
}
I am trying to vertically align the text content but it is refusing to be vertical aligned. I don't want to set any height on the image as don't want to ruin it's aspect ration, but need content to always be aligned in the remaining space left at all screen sizes.
below is a jsfiddle:
https://jsfiddle.net/a4n7drxf/
Any ideas on how to acheive this would be greatly appreciated

center align ul inside div with display:table [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
How to horizontally align ul to center of div?
(5 answers)
CSS center ul list inside a 100% width div
(2 answers)
How can I center <ul> <li> into a div?
(16 answers)
How do I center align horizontal <UL> menu?
(17 answers)
Closed 4 years ago.
I am trying to centrally align the ul li text inside the main div. Exactly text align center the text. I don't want to do it with the margin. What is an elegant way?
I need to keep the display table setup for vertical alignment.
MY HTML:
<div class="main-div">
<div>
<a class="navbar-brand" href="#">
Anchor
</a>
</div>
<ul>
<li>
<span>Center this</span>
</li>
</ul>
</div>
CSS:
.main-div {
width: 100%;
display: table;
}
ul {
display: table-cell;
vertical-align: middle;
}
li {
list-style: none;
}
CodePen is here

How do I center a DIV with no parent? [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
How do you easily horizontally center a <div> using CSS? [duplicate]
(22 answers)
Best way to center a <div> on a page vertically and horizontally? [duplicate]
(30 answers)
Closed 4 years ago.
I want to center my form in the center of teh horizontal row it is in. I thought this would be as simple as
#control {
text-align: center;
}
The element I want to center is
<div id="control" class="btn">
<div id="btn_container"><img width="100" height="100" src="https://cdn3.iconfinder.com/data/icons/minecraft-icons/512/Stone_Pickaxe.png" alt="Mining pick" /></div>
<span>Start</span>
</div>
However, the element is still not being centered -- https://jsfiddle.net/xwdnvcy5/58/ . I'm not getting something really obvious, but I can't tell what it is.
This one is not very intuitive, but try setting the margin to 0 auto.
#control {
margin: 0 auto;
}
The answer is quite simple actually. You need to set the margin-left/right as auto.. like this:
#control {
margin: 0 auto;
}
Are you try to center the #control div?
Try this
#control {
position:relative;
left: 50%;
transform: translateX(-50%);
}