My Bootstrap datepicker currently displays at the bottom left of the textbox, thats ok in a normal browser window. But the issue comes when the browser window is made small or resized. I want to make the datepicker display top left when the browser window is made small . Also on small screen I want the datepicker to become small also , but it should be readable and should also look good
Any help would be greatly appreciated
You want to use CSS media queries for different resolutions. eg.
#media (min-width: 768px) {
.some-class {
float: right;
width: some_width;
height: auto;
}
}
#media (min-width: 481px) and (max-width: 767px) {
.some-class {
float: left;
width: some_smaller_width;
height: auto (or some specific height);
}
}
more: w3schools/mediaqueries
Related
Cleck my site
https://webpconverterio.blogspot.com/
How to make the file upload button on center in mobile view
Check this image
Are you trying to achieve this with Javascript? This may be tagged wrong, looking at your website I was able to center the form by adding one simple line to the CSS styles:
[type=file] {
margin: 20px 0;
margin-left: 200px; /* this is causing you to add 200px of margin on the left /*
}
You can either remove that from the styles if you don't need it, or target mobile devices with the following css:
/* Extra small devices (phones, 600px and down) */
#media only screen and (max-width: 600px) {
[type=file] {
margin: 20px 0;
margin-left: 0;
}
}
Note, I haven't tested that css so you may need to modify it a bit. You can take a look here for adding media queries to your css styles to target different devices: https://www.w3schools.com/howto/howto_css_media_query_breakpoints.asp
input[type=file] {
margin: 20px 0;
margin-left: 200px;
}
the problem is here, you should make it responsive or use flex display (flex make it very easy).
however you can now add this to your css and make it right.
#media only screen and (max-width: 600px) {
input[type=file] {
margin: 20px 0;
margin-left: 20px;
}
}
I am setting up a website, and when I open it on mobile or resize the page too small, the logo at the top of the page resizes itself in a way that looks bad. It would be great if I could resize it to look good, but at this point I am running out of time and just want to make it disappear.
I have tried and failed to write JavaScript scripts to make it disappear. I can set the visibility to hidden, but I have no way to do this in a responsive way to the page getting resized and no way to detect if the webpage is too small to begin with. I have attempted to use the onresize DOM Event, but it doesn't seem to work.
Here is my attempt at getting HTML to use the JS function:
<a href="website.com" class="header_logo" id="main_logo" onresize="fixBar()">
<img src="image.png">
</a>
Here is the JS function (which is below all the HTML on the page) that is not working:
<script type="text/javascript">
function fixBar() {
if (window.innerWidth < 400px) {
document.getElementById("main_logo").style.visibility = "hidden";
} else {
document.getElementById("main_logo").style.visibility = "visible";
}
}
</script>
But as you can see, I still don't know how to check in the first place if the window is sufficiently small.
Also, I am working under restrictions that make it very difficult to use jQuery. If that is my only option then I will use it, but I would really prefer not to. Thank you for the help!
You can use CSS Media Query for responsiveness.
#media only screen and (max-width: 400px) {
#main_logo {
display: none;
}
}
<a href="website.com" class="header_logo" id="main_logo">
<img src="https://placeholder.pics/svg/200x50">
<div>Any HTML element</div>
</a>
Here, when the window size is less than 400px the element with id="main_logo" will be removed.
Another CSS rule would be visibility: hidden;
There is a difference between display: none; and visibility: hidden;
Check that out here
You can use a CSS media query to accomplish this:
#media only screen and (max-width: 400px) {
#main_logo {
visibility: hidden;
}
}
OK, if you can use CSS media query for those kind of problem.
#media screen and (max-width: 480px) {
image-container-class {
position: relative;
height: 90px;
width: 150px;
//display: none;
}
}
or if you are trying to hide logo on small devices, use display none. see the commented code at up.
I have the almost the same situation as yours; that if the screen width is less than the my specified width it should hide the div. This is the jquery code I used that worked for me.
$(window).resize(function() {
if ($(this).width() < 400) {
$('.divIWantedToHide').hide();
} else {
$('.divIWantedToHide').show();
}
});
You might want to combine it with a resize event with you can check you window size
$(window).resize(function() {
if ($(window).width() < 400) {
alert('Less than 400');
}
else {
alert('More than 400');
}
});
The #media rule is used in media queries to apply different styles for different media types/devices.
Media queries can be used to check many things, such as:
width and height of the viewport
width and height of the device
orientation (is the tablet/phone in landscape or portrait mode?)
resolution
Example :
#media only screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}
AND
#media only screen and (max-width: 400px) {
#main_logo {
display: none;
}
}
checkout CSS #media Rule Here
you can go with id and class id represent it with # and class represent it with dot i.e .
I have HTML div with width of 190 px that's working normal for desktop but for mobile its not , is there a way to tell if connection is from desktop take this value else take this value ?
this is my code :
document.querySelector('.article').style.width ='190px';
In your css file
// Desktop
.article {
width: 100px;
}
// Mobile
#media only screen and (max-width: 768px) {
.article {
width: 50px;
}
}
This are Media Queries.
In the first lines, we don't have any limitation, but then you override the current value ONLY when the width of the screen is lower than 768px
Just use media Queries which is the best option to make the things responsive .
Otherwise you can have a look at flexbox which is awesome flexbox
Use Media Queries
Using a breakpoint of 576px targets all kinds of mobile devices.
// This is the default size
.article {
width: 100px;
}
// Small devices (landscape phones, 576px and up)
#media (min-width: 576px) {
width: 200px;
}
The other answer targets tablets too. But if you want to target mobile only, use my solution.
I've designed a sign up box for my website using semantic ui. I used semantic ui card for image and it's center aligned. Then I put "Upload a photo" button underneath the image(not fluid because I need the button resize to the width of image when mobile).
I gave width for button manually and center it. Now it's looking good. The problem is the mobile version. It didn't scale to the image size when mobile because it's fixed width.
This is my code
<button className="fluid ui large red button upload-btn">Upload a Photo</button>
.driver-upload-btn{
width: 30.4%;
margin: 0 auto;
margin-top: 12px;
}
Do I need media query? I'm stuck here
you can try this,
#media screen and (min-width: 320px){
.driver-upload-btn{
width: 10.4%; //set width as whatever u want
}
}
// Media query list
#media screen and (min-width: 1024px){}
#media screen and (min-width: 768px){}
#media screen and (min-width: 640px){}
#media screen and (min-width: 480px){}
#media screen and (min-width: 320px){}
I have an requirement that an application(HTML, CSS and Javascript) should adjust automatically to screen window size - from laptops, to desktops to tablets.
Does anyone know how can this be done?
You need to study Responsive Design. But I'll tell you the big key: media queries.
With CSS like this
#media only screen and (max-width: 500px) {
#mydiv {
width: 80%;
}
}
#media only screen and (min-width: 501px) {
#mydiv {
width: 50%;
}
}
you can do all you need. In fact, for some screen sizes you can set #menu1 to display:none, and #menu2 to display:block, and thereby show entirely different layouts dynamically based on the screen size.
Try this link for a very minimal example you can play with
http://www.w3schools.com/css/tryit.asp?filename=tryresponsive_breakpoints