I'm trying to create a login page like this:
What I created so far looks like this:
With this code:
<div class="control-section" style="max-width: 100% !important;">
<div class="row" style="height:100%;">
<div class="col-md-4" style="height: 100% !important; padding-top: 25px !important;">
<section>
<form id="account" method="post">
<h4>LOGIN </h4>
<hr />
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="Input.Email"></label>
<input asp-for="Input.Email" class="form-control" />
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.Password"></label>
<input asp-for="Input.Password" class="form-control" />
<span asp-validation-for="Input.Password" class="text-danger"></span>
</div>
<div class="form-group">
<div class="checkbox">
<label asp-for="Input.RememberMe">
<input asp-for="Input.RememberMe" />
#Html.DisplayNameFor(m => m.Input.RememberMe)
</label>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Log in</button>
</div>
<div class="form-group">
<p>
<a id="forgot-password" asp-page="./ForgotPassword">Forgot your password?</a>
</p>
<p>
<a asp-page="./Register" asp-route-returnUrl="#Model.ReturnUrl">Register as a new user</a>
</p>
<p>
<a id="resend-confirmation" asp-page="./ResendEmailConfirmation">Resend email confirmation</a>
</p>
</div>
</form>
</section>
</div>
<div class="col-md-8" style="max-width: 100% !important; height: 100% !important;">
<img src="~/Resources/placeholderimage.png" />
</div>
</div>
</div>
#section Scripts {
<partial name="_ValidationScriptsPartial" />
}
<style>
.container {
max-width: 100% !important;
height: 100% !important;
}
.col-md-4 {
height: 100%;
display: table-row;
}
.col-md-8 {
height: 100%;
display: table-row;
}
img {
padding: 0;
display: block;
margin: 0 auto;
max-height: 100%;
max-width: 100%;
}
</style>
As u can see theres an empty white space at the bottom of the page even though I resized my image to huge dimensions, somehow it does not fit to the 100% of my page. How can I set the static height of 100% to my image? Hope someone can help.
Thanks
You can use 100vh instead of 100% on your img or col-md-8.
Possibly the image does not stretch the full width of col-md-8 in which case you can:
img {
width: 100%;
height: 100%;
object-fit: cover; /* cover makes the image stretch the width and height of the container */
}
And you can also make sure the col-md-8 takes up 100% of the height like this.
col-md-8 {
max-width: 100%;
height: 100vh;
}
Add CSS Media Query to change image fit on screens below 993px
#media and screen(max-width: 992px {
img{
object-fit: contain;
}
}
Although I would advise against it, if you must change the height of the element without changing the size of the parent, you should probably set the height: 100vh
Obviously since the viewport height is not calculated properly or as expected on mobile you should probably try to calculate the height of the window.innerHeight on window.addEventListener('load') and on window.addEventListener('resize') using something like this:
const vh = window.innerHeight * 0.01
document.documentElement.style.setProperty('--vh', `${vh}px`)
window.addEventListener('resize', () => {
const vh = window.innerHeight * 0.01
document.documentElement.style.setProperty('--vh', `${vh}px`)
})
Then applying it to your element as so: height: calc(var(--vh, 100vh) * 100)
Obviously a simpler solution would be using height: 100% and you would avoid any possible overflow.
Try this:-
Remove height from row and columns and give this class in row m-0
<div class="col-md-8" !important;">
<class ="bk-one-more-div"style="width: 100%!important; height: 500px>
<img src="~/Resources/placeholderimage.png" class="img-fluid w-
100">
<div/>
</div>
Related
I am new to react.
I a trying to setup a little app. On home page we have carousel.
My home page code is:
render(){
return (
<div className="main-page">
<div className="row full-height">
<div className="common-info col-lg-7">
<div className="row center-lg logo-container">
<LogoImg/>
</div>
<CarouselComponent/>
</div>
<div className="login-form col-lg-5">
<div className="justify-content-end">
</div>
</div>
</div>
</div>
)
}
In scss:
I set up
.main-page {
height: 100vh;
width: 100vw;
}
Everything works fine until adding
with
return (
<div className="carousel-outer">
<Carousel showArrows={true} showThumbs={false} showStatus={false}>
<div>
<p className="row center-lg learn-eng white-text">Выучи английский</p>
<p className="row center-lg easy-fast white-text">Легко и быстро!</p>
<p className="row center-lg go-abroad white-text">Для поездок за границу</p>
<img src={vacation}/>
</div>
<div>
<img src="assets/2.jpeg"/>
</div>
<div>
<img src="assets/3.jpeg"/>
</div>
</Carousel>
</div>
);
I tried to add styles to Carousel:
.carousel .carousel-slider {
max-width: 100%;
max-height: 100%;
}
.carousel-style {
height: auto;
width: auto;
}
But images are still outside parent container. Horizontal an vertical scrolls are there:
How can I fix the issue?
Work Demo
I could not modify your project but I made a sample .
tip:
.container {
width: 100%;
}
.container .carousel .slide img {
max-height: 100vh;
width: auto; /*100vw*/
}
Work Demo
There are 3 images on my homepage that I want to make responsive. They are not scaling. I have removed any reference to height or width size in the html. I tried to use the CSS rule max-width that targets the image as a percentage relative width value, but can't get it to work.
My html looks like this:
<div class ="wrapper2">
<div>
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/kidsspecialevents.jpg" /></div>
<div>
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/teenspecialevents.jpg" /></div>
<div>
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/adultspecialevents.jpg" /></div>
</div>
The css (that doesn't work) looks like this:
.wrapper img {max-width:100%;}
Any help with this would be appreciated. I've been working on and off with it for months! Thank you
Like Rob said, the .wrapper img {max-width:100%;} only tells the browser you don't want the image to be wider the 100% of the browser window's width.
Check out this code pen with your supplied HTML that shows want you'd like: Code Pen
The width is now set to 50% and the height is set to auto. The images will now take up 50% of the browser window's width and adjust their height to match the original aspect ratio.
Here's just the CSS:
.wrapper2 img {
height: auto;
width: 50%;
}
i made this code if you like.
.wrapper2 img {
height: auto;
width: 100%;
}
.wrapper2 div { float:left; width:33.33%; positive:realtive;}
<div class ="wrapper2">
<div>
<a href="https://www.whitehallpubliclibrary.org/kids-parent/kids/special-events-for-kids/">
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/kidsspecialevents.jpg">
</a>
</div>
<div>
<a href="https://www.whitehallpubliclibrary.org/teens-parent/teens/special-events-for-teens/">
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/teenspecialevents.jpg">
</a>
</div>
<div>
<a href="https://www.whitehallpubliclibrary.org/adults-parent/adults/special-events-for-adults/">
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/adultspecialevents.jpg">
</a>
</div>
</div>
Thank you
Please try this -
<div class ="wrapper2">
<div>
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/kidsspecialevents.jpg" />
</div>
<div>
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/teenspecialevents.jpg" />
</div>
<div>
<img src="https://www.whitehallpubliclibrary.org/wp-content/uploads/2019/09/adultspecialevents.jpg" />
</div>
</div>
.wrapper2 {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.wrapper2 div {
width: calc(100%/3 - 2%);
margin: 0 1%;
}
.wrapper2 div a, .wrapper2 div img {
width: 100%;
}
I am using owl carousel 2 and my problem is that I am looking for a solution to maintain images' aspect ratio while users resizing the browser window (responsiveness) based on the graphist's design.
which makes the developing harder, each item is a carousel includes 3 pictures,
I use this function in Scss to make my images 16:9 :
#function aspect($width) {
#return $width * 9 / 16;
}
which is not very interactive and always returns the static size of the image (though I've written media queries in different scales, still it's not very stable)
here is my carousel init code:
$('.owl-carousel').owlCarousel({
nav: false,
dots: true,
items: 1,
center: true,
//autoWidth: true,
loop: true,
});
and my HTML code is :
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-12">
<a href="#Url.Action("Video", "Service")">
<div class="owl-carousel owl-theme">
<div class="item">
<img src="#service.serviceThumbpath" alt="#service.serviceName" title="#service.serviceName" />
</div>
#foreach (var thumb in videoThumbpath)
{
<div class="item">
<img src="#thumb" alt="#serviceName" title="#serviceName" />
</div>
}
</div>
<h5> #service.serviceName</h5>
<div class="details">
#{
_serviceRate = float.Parse(service.serviceRate);
}
<p class="pull-left">#service.VideoCount </p>
</div>
</a>
</div>
is there any solution that I can make it responsive images through owl carousel 2?
thanks a lot
I found the solution, I added these styles to my Scss file:
.outer {
position: relative;
&:before {
display: block;
content: "";
width: 100%;
padding-top: (9 / 16) * 100%;
}
> .inner {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 100%;
}
}
Then I changed my Html like this:
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-12">
<a href="#Url.Action("Video", "Service")">
<div class="owl-carousel owl-theme">
<div class="item outer">
<img src="#service.serviceThumbpath" alt="#service.serviceName" title="#service.serviceName" class="inner"/>
</div>
#foreach (var thumb in videoThumbpath)
{
<div class="item outer">
<img src="#thumb" alt="#serviceName" title="#serviceName" class="inner"/>
</div>
}
</div>
<h5> #service.serviceName</h5>
<div class="details">
#{
_serviceRate = float.Parse(service.serviceRate);
}
<p class="pull-left">#service.VideoCount </p>
</div>
</a>
</div>
and it worked maintaining 16:9 aspect ratio with owl carousel 2 :)
for the grid system of the page, I used This CodePen which was really helpful for my custom sizes.
Something like this should work. Adding an fixed width to container. Then with the img css it should keep its aspect ratio, as you aspect.
.item {
width: 100px;
}
img {
display: block;
width: 100%;
height: auto;
}
<p>This image is originally 400x400 pixels, but should get resized by the CSS:</p>
<div class="item">
<img width="400" height="400" src="#service.serviceThumbpath" alt="#service.serviceName" title="#service.serviceName" />
</div>
Just an example , you can use your own widths and heights. Could also add .item width only at certain #media query.
I set the height and width as below:
.owl-carousel {
height: 100%;
overflow: hidden;
}
.owl-carousel .owl-item img {
display:block;
height:100%;
width: auto;
}
jQuery:
owl.owlCarousel({
items:3,
autoWidth: true,
});
I have this code in CSS:
<div class="col-lg-6" style="">
<img src="images/team1.jpg" alt="portfolio img" style="margin-top: 15%; max-height: 270px; width:100%"/>
</div>
I need to use auto crop the image instead of compressing the image and become pixelated,
Ive tried max-height still doesnt work ? any idea for this ?
Style your div with width, height and overflow:hidden
div {
width: 300px;
height: 300px;
overflow: hidden;
}
<div>
<img src="http://lorempixel.com/640/650/cats" alt="portfolio img />
</div>
<div class="col-lg-6" style="max-height: 500px; overflow:hidden;">
<img src="images/team1.jpg" alt="portfolio img" style="margin-top: 15%; width:100%"/>
</div>
I have the following html:
<div id="holder">
<span>Search for</span>
<input id="srchfor" />
<span>near</span>
<input id="srchin" />
<span>submit</span>
</div>
The containing div is fixed width. The width of the 3 spans will depend on font size. Is it possible to make the two inputs take a width so that they are both equally sized, and they consume all the remaining space in holder? Or does this require using javascript?
Edit: My aim is to have the 5 elements all on one line, rather than split over several lines.
This is an old post but I came across it and figured I would answer it for the next person. Here is a CSS/HTML snippet that should resolve this issue. It is kind of like a HTML5 flexbox but without HTML5 or a flexbox. You can add width to whatever 2 sections needed and the third will fill the remaining void.
<style type="text/css">
.form-group {
border: 1px solid black;
margin-bottom: 20px;
padding: 10px;
width: 75%;
}
.a {
float: right;
margin-left: 10px;
width: 30%;
}
.a input {
width: 100%;
}
.b {
float: left;
margin-right: 10px;
width: 33%;
}
.b input {
width: 100%;
}
.c {
display: block;
overflow: hidden;
}
.c input {
width: 100%;
}
</style>
<div id="wrapper">
<div class="form-group">
<span class="a">
<label>Thing 1</label><br />
<input type="text" />
</span>
<span class="b">
<label>Thing 2</label><br />
<input type="text" />
</span>
<span class="c">
<label>Thing 3</label><br>
<input type="text" />
</span>
</div>
<div class="form-group">
<div class="a">
<label>Thing 1</label><br />
<input type="text" />
</div>
<div class="b">
<label>Thing 2</label><br />
<input type="text" />
</div>
<div class="c">
<label>Thing 3</label><br>
<input type="text" />
</div>
</div>
</div>
Well, you could change the display type from display: inline to display: block to make them fill space. But I don't know if the inline is an requirement.
You have to choose a fixed width for the span elements, and use the display:inline-block property like in this example.