So i have a button which should be positioned to the right side of the page, But when site loads on mobile, i want it to center in the very middle of the Logo but instead renders right but incomplete and when it is rendered on desktop, it renders way to the left.
Here is how it looks on Mobile:
Desktop:
So anyway to achieve this ? Here is a bit of the code:
.mainBanner input{
position: relative;
left: 70%;
}
#buttonPush{
height: 35px;
width: 95px;
background-color:#1abc9c;
border: none;
color: #fff;
border-radius: 3px;
font-size: 22px;
border-bottom: 2px solid #16a085;
/*position: absolute;
left: 90%;*/
}
Here is the HTML code:
<header>
<div class="mainBanner">
<img id="mainLogo" src="img/logo.png">
<!--POST BUTTON-->
<div id="buttonPost"> <form action="#openModal"><input id="buttonPush" type="submit" value="Post"></form></div>
</div>
For that you need to use CSS3 Media Query.
Using that, you can change the CSS properties of the elements. Here is a general example:
#media only screen and (max-width: 900px) {
// properties here..
}
Now if you want to change the properties for a screen that is a bit shorter in size:
#media only screen and (max-width: 300px) {
// properties here...
}
Using this, you can change the style of the website on different screen types and sizes. You can also change the theme depending on whether the screen is mobile or desktop.
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries
Related
I am working on a website in which I want search button to look same across all mobile and tablet devices. I have created the fiddle for that. The code which I have used for the search button (for mobile/tablet view) is:
#media only screen and (max-width: 767px) {
#gv_search_button_2777 {
padding-left: 5.5%;
padding-top: 0.5%;
padding-bottom: 0.5%;
padding-right: 5.5%;
background-color: white;
font-size: 12px;
border-radius: 3.5px;
border: 1px solid #ccc!important;
}
}
<div class="gv-search-box gv-search-box-submit">
<input type="hidden" name="mode" value="all">
<input type="submit" class="button gv-search-button" id="gv_search_button_2777" value="Search">
</div>
Problem Statement:
If I take the above fiddle in the mobile view from the actual browser it looks good but if I see it from my phone it looks different.
Here is the screenshot for the Search button which I want to look on all mobile devices:
I am wondering what changes I need to make in the CSS codes in my fiddle so that above screenshot is present on all devices.
On my iphone when checked on safari and chrome, I am seeing this(which is not right):
You can set appearance: none to tell iOS Safari (and others) not to apply OS native styling to the element:
.button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
From there you can reset browser stylesheet attributes (e.g. margin, padding, font, etc) and apply your own custom styles.
as you can see in my website http://sunray.co.il/en/
when tryin to set broswer size to mobile size, you cant see all the "google map" block, hope that you can help me guys, thanks!
example
You can edit global.css:8386
#media (max-width: 991px){
#cmsinfo_block {
min-height: 554px;
height: 554px;
padding-left: 13px;
padding-right: 13px;
}
}
The website is freetorun.net in wordpress. When viewed on mobile devices the gold "Sign up" button is not centered on the screen.
I was thinking that changing the font-size to 14px in the CSS would fix it:
.large.custom-button span:visited {
font-size: 14px;
padding: 9px 14px 9px;
}
This code is not working though.
The target HTML is this:
<a class="large custom-button align-btn-right" href="http://freetorun.net/wordpress/choose/" title="Register Today!"><span style="background-color:#DAA520; color:#26354A">to start running faster, farther and<br> injury free SIGN UP for a clinic!</span></a>
Your layout on mobile has lots of issues with padding and floated elements. Changing the font size won't help with positioning.
Firstly the div with class social_media_top widget_text substitute_widget_class should probably be full width, and text-align: center;
You also need to remove the float: right on the gold button.
For the record, I did not solve this. And the code provided above didnt either. But the guys who wrote the U-Design theme gave me this and it is much better.
#top-elements .social_media_top {
clear: both;
float: right;
margin-left: -150px;
margin-top: -20px;
padding: 0 20px 0 0;
}
/* Mobile Screen ( smaller than 480px )*/
#media screen and (max-width: 480px) {
#top-elements .large.custom-button span,
#top-elements .large.custom-button span:visited {
font-size: 14px;
}
#top-elements .social_media_top {
padding: 0;
}
}
I have some text on my site that I want to be visible on mobile phones but not on computers. I tried with "display: none" in my CSS file and "Display: block" in my mobile queries, but it doesn't work for some reason (not even if I use !important). It do, however, work if I use the visible property, but I don't want to use that.
Here is a jsfiddle: https://jsfiddle.net/5y2vsmtz/2/
Or you can see the text here:
HTML:
<div class="mobiltext1">
<div>Heading 1e<br></div>
Description 1<br>
<div>Heading 2<br></div>
Description 2<br>
<div>Heading 3<br></div>
Description 3<br>
</div>
CSS:
#media only screen and (max-width: 380px){
.mobiltext1 {display:block; padding-top:30%;}
}
.mobiltext1 {
display: none;
font-family: Raleway Bold, sans-serif;
text-align: center;
padding-top: 5%;
letter-spacing: 2px;
color: rgba(80,80,80,0.99);
}
Increasing the max-width will allow it to work for more mobile devices.
Placing the #media css below the normal css causes it to override the former.
.mobiltext1 {
display: none;
font-family: Raleway Bold, sans-serif;
text-align: center;
padding-top: 5%;
letter-spacing: 2px;
color: rgba(80,80,80,0.99);
}
#media only screen and (max-width:500px){
.mobiltext1 {display:block; padding-top:30%;background-color:red}
}
see fiddle: https://jsfiddle.net/pcoyc4ay/
So I have the following in a Bootstrap 3 document:
<div class="col-xs-10 col-lg-12 col-md-12 text-center">
<a class="btn btn-success btn-lg btn-xl" href="#package-details">
<span class="text-uppercase"><span class="text-white-dark">Pre-Order & </span>Pledge Now</span>
</a>
</div>
With 1 css rule override:
.btn-xl {
font-size: 34px;
padding: 8px 10px;
border-radius: 6px;
}
But on a small device it hangs off the screen. On the larger devices it looks fine.
How do I get this to be about 80% width (as opposed to the current 105%) on a small screen, without affecting the current size on the others?
In other words, what I want to happen is whenever a mobile device loads my site, I want the button to be big...but not overflowing off the page. It doesn't even have to be the same proportion as it is for larger screens via col-md-* and col-lg-*.
Note that I don't want to use JS, just CSS.
You can see it live here
Figured it out myself:
#media (max-width: 400px) {
h1 {
margin-top: 5px;
padding-top: 10px;
}
.btn-xl {
font-size: 22px;
padding: 10px 16px;
border-radius: 6px;
margin-left: auto;
margin-right: auto;
}
}