I have the following issue, where I want to move the logo to the position shown in the picture
Im able to move the image around using properties like:
.img-logo{
display:flex;
position: absolute;
text-align: center;
align-items: center;
justify-content: center;
left: 50%
}
But the point is, those are not exact values, I dont know how to do it with exact values
Because if I use
.img-logo{
display:flex;
position: relative;
text-align: center;
align-items: center;
justify-content: center;
}
The image wont even move
The htlm is like this
<div class="main">
<form class='login-form' onSubmit={this.handleSubmit}>
<img alt="image" src={brand} width="60" height="60" class="img-logo"/>
<p class='lf--upper-text' >Welcome to app</p>
<div class="flex-row">
<label class="lf--label" htmlFor="email">
<svg x="0px" y="0px" width="12px" height="13px">
where .main
.main { height: 100%; }
.main {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
position: relative;
and .login-form
.login-form {
width: 100%;
padding: 2em;
position: relative;
background: white;
border-radius: 30px;
#media screen and (min-width: 600px) {
width: 50vw;
max-width: 15em;
}
}
Fixed it
<div class="flex-row img-logo">
<img src={brand} width="60" height="60" class="img-logo-in" />
</div>
css
.img-logo{
display:flex;
position: relative;
text-align: center;
align-items: center;
justify-content: center;
bottom: 20%
}
.img-logo-in{
position:absolute;
left:50%;
transform:translate(-50%); }
Related
I'm trying to make an item center,but somehow it not work
Here is html part:
<div>
<div className={styles.unanswerQuestionContainer}>
<div className={styles.headerContainer}>
<div>Unanswered Questions</div>
<div>Answered Questions</div>
</div>
</div>
</div>
Here is css part:
.unanswerQuestionContainer {
height: 60vh;
width: 60vw;
border: 1px solid;
display: flex;
margin: 20px 0 0 0;
align-self: center;
}
.headerContainer {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
}
But it show something like this:
It do not center the div, how can i center this ??
Edit: When i try to inspect then it show all of this is margin:
You need to add following style to outer div(parent) unanswerQuestionContainer
display: flex;
justify-content: center;
align-items: center;
height: 100%;
body{
height: 100vh;
margin: 0;
}
.unanswerQuestionContainer {
height: 60vh;
width: 60vw;
border: 1px solid;
display: flex;
margin: 20px 0 0 0;
align-self: center;
}
.headerContainer {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
}
.outer{
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
<div class="outer">
<div class="unanswerQuestionContainer">
<div class="headerContainer">
<div>Unanswered Questions</div>
<div>Answered Questions</div>
</div>
</div>
</div>
You will have to adjust which css properties you will use in order to prevent the two h1 from overlapping.
<div className={styles.unanswerQuestionContainer}>
<div class="Questions">
<p id="question-type">Answered Question</p>
<p id="question-type">Unanswered Question</p>
</div>
</div>
.questions h1 {
width: 100px;
height: 100px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
I'd like the navigation arrows to align vertically middle.
On the live site they are off-center.
There is compromising CSS I can't change which sets a top: 40% for the arrows (.owl-nav button).
I've tried unseting their top, but this pushes them to underneath the image.
I've tried setting top: calc(50% - 37.5px); (minus half the button's height of 75px) but this is off-center. Is my math right here?
I've been able to get it working below by using a fixed height for .owl-nav.pp-carousel-nav but on the live page the .owl-items are not of fixed width and height, they are responsive.
.owl-carousel .owl-stage {
position: relative;
}
.pp-content-post-carousel {
position: relative;
}
.landscape-carousel-container {
width: 100%;
}
.landscape-carousel-content {
width: 100%;
}
.landscape-carousel-overlay {
position: absolute;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
height: 236px;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
opacity: 0;
transition: .4s ease !important;
border-radius: 15px;
background-color: #22a1d9;
}
.landscape-carousel-img {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
height: 236px;
margin-bottom: 10px;
padding-bottom: 0px;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
background-color: rgba(14,34,129,0);
background-image: url("https://cdn-ehbod.nitrocdn.com/MnwLQZiWrxfKgQoPapfeSJHycGHMrPjW/assets/static/optimized/rev-315e7f6/img/background-image.svg");
background-position: 50% 50%;
background-size: cover;
background-repeat: no-repeat;
-webkit-transition: all 200ms ease;
transition: all 200ms ease;
cursor: pointer;
border-radius: 15px;
border: 3px solid #dfefef;
}
.owl-nav.pp-carousel-nav {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 242px;
width: 370px;
position: absolute;
top: 10px;
}
.owl-nav button {
position: absolute;
line-height: 1;
margin: 0;
font-size: 20px;
background: none !important;
z-index: 1;
border: none;
background-color: transparent;
}
.owl-nav button.owl-prev {
left: -15px;
}
.owl-nav button.owl-next {
right: -15px;
}
.owl-nav button svg {
width: 51px;
height: 51px;
color: white;
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
padding-left: 10px;
}
.sr-only {display: none;}
<div class="owl-item cloned" style="width: 370px;">
<div class="pp-content-post pp-content-carousel-post pp-grid-custom post-6474 templates type-templates status-publish hentry templatecategory-hospitality templatecategory-landscape-liquor-hospitality-2 templatecategory-liquor" itemscope="" itemtype="https://schema.org/CreativeWork" data-id="6474" style="visibility: visible; height: 269.2px;">
<div class="landscape-carousel-container">
<div class="landscape-carousel-content">
<div class="landscape-carousel-overlay">
Edit this Template </div>
<div style="background-image: url("https://cdn-ehbod.nitrocdn.com/MnwLQZiWrxfKgQoPapfeSJHycGHMrPjW/assets/static/optimized/rev-315e7f6/wp-content/uploads/2021/06/landscape_Hospitality_Liquor_001.jpg");" class="landscape-carousel-img lazyloaded" nitro-lazy-bg="https://cdn-ehbod.nitrocdn.com/MnwLQZiWrxfKgQoPapfeSJHycGHMrPjW/assets/static/optimized/rev-315e7f6/wp-content/uploads/2021/06/landscape_Hospitality_Liquor_001.jpg"></div>
<div>Liquor Store - Many Bottles</div>
</div>
</div>
</div>
</div>
<div class="owl-nav pp-carousel-nav">
<button type="button" role="presentation" class="owl-prev">
<svg aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512">
<path fill="currentColor" d="M25.1 247.5l117.8-116c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L64.7 256l102.2 100.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L25 264.5c-4.6-4.7-4.6-12.3.1-17z" class=""></path>
</svg>
<span class="sr-only">Previous</span>
</button>
<button type="button" role="presentation" class="owl-next">
<svg aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512">
<path fill="currentColor" d="M166.9 264.5l-117.8 116c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17L127.3 256 25.1 155.6c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.7-4.7 12.3-4.7 17 0l117.8 116c4.6 4.7 4.6 12.3-.1 17z" class=""></path>
</svg>
<span class="sr-only">Next</span>
</button>
</div>
Here the answer as stated in the comment:
The problem is caused by the navigation elements parent box. It also includes the text below - therefore, you don't center it relative to the image, but to the image & its descriptive text. As you probably cannot change the html structure here I suggest you simply change the css calculation by to something like
top: calc(50% - 45px);
The height of the button is 66px and positions in relation to the div with class="pp-content-post-carousel pp-equal-height clearfix" which is 33.19px taller than the images.
I know I can easily achieve this kind of layout using the css float which is the current way I have the divs have the layout right now. But, I am trying to recode it and change it to flex alignment.
Here is my markup:
<div id="the-posts">
<div class="the-post-inner">
<a href="#">
<div class="image" style="background-image: url(https://www.dike.lib.ia.us/images/sample-1.jpg/image);"></div>
<div class="content"><h2>Post 1</h2></div>
</a>
<a href="#">
<div class="image" style="background-image: url(https://www.dike.lib.ia.us/images/sample-1.jpg/image);"></div>
<div class="content"><h2>Post 2</h2></div>
</a>
<a href="#">
<div class="image" style="background-image: url(https://www.dike.lib.ia.us/images/sample-1.jpg/image);"></div>
<div class="content"><h2>Post 3</h2></div>
</a>
</div>
</div>
And here is my CSS:
.the-post-inner {
clear: both;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
align-content: flex-start;
}
.the-post-inner a {
margin-bottom: 4%;
}
.the-post-inner a .image {
padding-bottom: 60%;
}
.the-post-inner a .content {
padding: 20px;
}
.the-post-inner a .content h2 {
margin: 0;
}
.the-post-inner a:first-child {
flex: 0 0 60%;
margin-right: 4%;
}
.the-post-inner a:not(:first-child) {
margin-right: 0;
flex: 0 0 36%;
align-self: flex-start;
overflow: hidden;
float: left;
display: block;
}
I tried several codes based on the answers in other posts but I can't seem to make this work.
Thanks in advance for the suggestions.
EDIT:
I was wondering if there is a way to achieve this without changing the current markup which is not to separate the left post in another div and the right posts in another container.
https://jsfiddle.net/pextb1of/
I just put some fix. maybe will help you.
.the-post-inner {
clear: both;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
align-content: flex-start;
flex-direction: column;
height: 100px;
border: 1px solid #000;
}
a {
/*border: 1px solid #000;*/
margin-bottom: 4%;
/*padding: 20px;*/
}
.the-post-inner {
flex: 0 0 60%;
margin-right: 4%;
}
.sec-inner {
margin-right: 0;
flex: 0 0 36%;
align-self: flex-start;
flex-direction: column;
overflow: hidden;
float: left;
display: flex;
}
#the-posts{
display: flex;
flex-direction: row;
}
<div id="the-posts">
<div class="the-post-inner">
Post 1
</div>
<div class="sec-inner">
Post 2
Post 3
</div>
</div>
I'm a React beginnerCan you explain me how to place a .herogroup (composed by h1, p and a button) in the middle and 20px far away from the bottom of a background (belonging to .Hero)?
<div>
<div className="Hero">
<div className="HeroGroup">
<h1>ABC</h1>
<p>ABC</p>
<Link to="ABC">ABC</Link>
</div>
</div>
CSS
.Hero {
height: 1920px;
background-image: url('../images/abc.jpg');
background-size: cover;}
.HeroGroup{
max-width: 500px;
margin: 0 auto;
padding: 150px 50px;
text-align: center;}
I have used css flex. Which is more convenient to achieve your case than using position absolute.
.Hero {
height: 1920px;
background-image: url('../images/abc.jpg');
background-size: cover;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.HeroGroup{
max-width: 500px;
margin: 0 auto;
padding: 20px 0px;
display: flex;
/* flex-wrap: wrap; */
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
<div>
<div class="Hero">
<div class="HeroGroup">
<h1>ABC</h1>
<p>ABC</p>
<Link to="ABC">ABC</Link>
</div>
</div>
In your .HeroGroup class do this
.HeroGroup {
max-width: 500px;
padding: 150px 50px;
margin: 0 auto;
text-align: center;
position: absolute;
bottom: -20px;
}
.main-content{
height: 100%;
width: 60%;
min-height: 800px;
background-color: white;
border-radius: 5px;
margin-left: 1%;
border: solid 1px black;
}
.profile-banner{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: 100%;
height: 7vw;
margin-top: 7%;
background-color: rgba(71, 135, 195, 0.5);
}
.profile-avatar{
width: 18%;
margin-right: 3%;
img{
width: 100%;
border: solid white 2px;
}
}
.profile-username{
margin-left: 5%;
font-size: 4vw;
color: $font-blue;
font-family: 'Titillium Web', sans-serif;
-webkit-text-stroke: 1px white;
}
.profile-second-sec{
margin-top: 8%;
height: 20vw;
background-color: blue;
}
.profile-third-sec{
display: flex;
flex-direction: row;
align-items: center;
margin-top: 8%;
height: 30vw;
background-color: grey;
overflow-x: scroll;
white-space: nowrap
}
.profile-image-container{
display: flex;
align-items: center;
}
<div class="main-content">
<div class="tab-header font-large">
<i class="fa fa-user"></i> User profile
</div>
<div class="profile-banner flerowspb">
<div class="profile-username">
User profile
</div>
<div class="profile-avatar">
Avatar image
</div>
</div>
<div class="profile-second-sec">
</div>
<div class="profile-third-sec">
>> This is where the images go <<
</div>
</div>
EDIT: added in code snippit, Hope it helps
I trying to create a horizontal scroll div but when i add the content images all it does is squeeze all the images inside of it like so,
So its resizing the images to fit in but i would like them to be normal size and be able to scroll.
Now i tried to add overflow scroll but its not having that effect
.profile-third-sec{
display: flex;
flex-direction: row;
align-items: center;
margin-top: 8%;
height: 30vw;
background-color: $font-grey;
overflow-x: scroll;
}
.profile-image-container{
display: flex;
align-items: center;
}
Now i thought i knew enough on this to be able to do but obviously not! So any ideas will be appreciated.
Thanks
You can remove the flexbox rules. Then provide the image with some properties. Using white-space and overflow should work for you.
example:
.main-content {
height: 100%;
width: 60%;
min-height: 800px;
background-color: white;
border-radius: 5px;
margin-left: 1%;
border: solid 1px black;
}
.profile-banner {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: 100%;
height: 7vw;
margin-top: 7%;
background-color: rgba(71, 135, 195, 0.5);
}
.profile-avatar {
width: 18%;
margin-right: 3%;
img {
width: 100%;
border: solid white 2px;
}
}
.profile-username {
margin-left: 5%;
font-size: 4vw;
color: $font-blue;
font-family: 'Titillium Web', sans-serif;
-webkit-text-stroke: 1px white;
}
.profile-second-sec {
margin-top: 8%;
height: 20vw;
background-color: blue;
}
.profile-third-sec {
margin-top: 8%;
height: 30vw;
background-color: grey;
overflow-x: scroll;
white-space: nowrap
}
.prgile-third-sec img {
display: block;
width: 100%;
height: auto;
}
.profile-image-container {
display: flex;
align-items: center;
}
<div class="main-content">
<div class="tab-header font-large">
<i class="fa fa-user"></i> User profile
</div>
<div class="profile-banner flerowspb">
<div class="profile-username">
User profile
</div>
<div class="profile-avatar">
Avatar image
</div>
</div>
<div class="profile-second-sec">
</div>
<div class="profile-third-sec">
<img src="https://unsplash.it/300">
<img src="https://unsplash.it/300">
<img src="https://unsplash.it/300">
<img src="https://unsplash.it/300"></div>
</div>
Flex have default wrap property, you can try on your code based on following stylesheet.
.className {
display: flex;
flex-wrap: nowrap;
overflow: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.class {
display: flex;
flex-wrap: nowrap;
}