How can I make an element with class properties display as inline-block for laptops and desktops and a list for tablets and mobiles?
Whenever I shrink the width of my browser, iPad design elements do not fit properly.
.properties {
display: inline-block;
}
#media screen and (min-device-width: 1200px) and (max-device-width: 1600px) and (-webkit-min-device-pixel-ratio: 1) {
.properties {
display: inline-block;
}
.propertyButton {
display: inline-block;
}
}
#media (max-width: 900px) {
.properties {
display: list-item;
list-style-type: none;
}
.propertyButton {
margin-top: -2%;
margin-left: 30%;
}
}
<div class="propertyWrapper" style="width:100%;">
<div style="float:right">
<span ng-click="addProperty()" class="button buttonPrimary pull-right">Add Property</span>
</div>
<div class="properties">
<label>Name</label>
<input type="text" />
</div>
<div class="properties">
<label>Name</label>
<input type="text" />
</div>
<div class="properties">
<label>Name</label>
<input type="text" />
</div>
<div class="properties">
<label>
IsRequired(TE):
</label>
<input type="checkbox" ng-model="property.TradeEarthRequired" name="UsedEquipmentPropertyList[0].TradeEarthRequired" class="ng-pristine ng-valid">
</div>
<div class="propertyButton">
<span class="button primaryAction" ng-click="addProperty()">Add</span>
<span class="button primaryAction" ng-click="removeProperty(property,$index)">Delete</span>
</div>
</div>
Sometimes, you just need to duplicate the code.
Keep an inline-block view for windows sized over 1200.
When you are under 1200, just hide it and show a fresh new list ?
I think you've just got your CSS a bit wrong - the media queries shouldn't be nested like that, as far as I can tell. Is this JSFiddle more like what you wanted?
.properties {
display: inline-block;
}
#media screen and (min-device-width: 1200px) and (max-device-width: 1600px) and (-webkit-min-device-pixel-ratio: 1) {
.properties {
display: inline-block;
}
.propertyButton {
display: inline-block;
}
}
#media screen and (max-width: 900px) {
.properties {
display: list-item;
list-style-type: none;
}
.propertyButton {
margin-top:-2%;
margin-left: 30%;
}
}
Related
I have developed a custom quote form for a client and when the user scroll down I add a class called .quoteform-fixed it also has an id called #quoteForm however I am trying to hide the entire quote form using media queries. Here is the css I am using....
#media screen and (max-width:1670px) and (min-width:1199px){
.quoteform-fixed {display:none !important}
}
#media screen and (max-width:1198px) and (min-width:767px){
.quoteform-fixed {display:none !important}
}
#media screen and (max-width:766px) and (min-width:220px){
.quoteform-fixed {display:none !important}
}
Here is the main rules for quoteform-fixed...
.quoteform-fixed {
position: fixed;
top: 35px;
right: 35px;
display: block;
}
here is the form HTML...
<div id="quoteForm" class="quote-form">
<div id="quoteFormHead"></div>
<form action="<?php the_permalink(); ?>" method="post">
<div id="quoteFormBody">
<div class="formfullwrapper">
<input type="text" name="message_fname" placeholder="Enter your full name here...">
</div>
<div class="formfullwrapper">
<input type="email" name="message_email" placeholder="Enter your email address here...">
</div>
<div class="formfullwrapper">
<input type="number" name="message_phone" placeholder="Enter your phone number here...">
</div>
<div class="formfullwrapper">
<textarea name="message_msg" placeholder="Details, please! Audience? Word count? Type of document? Tone? Deadlines? Sensitive content?"></textarea>
</div>
</div>
<div id="quoteFormFooter">
<div class="formfullwrapper">
<input type="submit" id="submitform" value="Get my free quote">
</div>
</div>
</form>
</div>
And here is the Javascript to add the class on scroll...
window.onscroll = function(){
var top = window.pageYOffset || document.documentElement.scrollTop;
var form = document.getElementById('quoteForm');
if (top > 800) {
form.classList.add("quoteform-fixed");
} else {
form.classList.remove("quoteform-fixed");
}
}
Many thanks,
Phillip
Not sure why you are adding three media queries to apply the same property, but creating it with the max and min flipped should work.
form {
width: 100vw;
height: 600px;
background: tomato;
}
#media (min-width: 300px) and (max-width: 600px) {
.quoteform-fixed {
display: none;
}
}
<form class='quoteform-fixed'>
</form>
Our team is new to responsive design and is trying to code with a mobile first framework. We're trying to use media queries to scale up in screen size, but can't seem to get it to work correctly. This is what our CSS looks like so far:
.flex, .cards, .card {
display: flex;
}
.flex {
flex-wrap:wrap;
}
.cards, .card {
align-items:center;
}
.cards {
padding: 1em;
background-color: $color-lightest;
box-shadow: 0px 1px 22px 4px rgba(0, 0, 0, 0.07);
}
#media screen and (min-width: 480px) {
.cards {
width: 49%;
margin: 1%;
}
.cards:nth-of-type(even) {
margin-right: 0;
}
.cards:nth-of-type(odd) {
margin-left: 0;
}
}
#media screen and (min-width: 1024px) {
.cards {
width: 32%;
margin: 1%;
}
.cards:nth-of-type(3n) {
margin-right: 0;
}
.cards:nth-of-type(3n+1) {
margin-left: 0;
}
}
The result of this looks like this when we set the screen size to exactly 1024px:
When we inspect the div, it looks like both the media queries css for 480px and 1024px are firing. What are we doing incorrect here?
EDIT: adding HTML
<div class="flex" ng-init="init(user.sys_id)">
<div class="cards" ng-repeat="task in data.tasks | orderBy: ['order']" >
<div class="card" ng-click="c.onWidget(task);">
<i ng-if="task.finished" class="{{task.icon}} fa-5x card-img finished" aria-hidden="true"></i>
<i ng-if="!task.finished && task.isOverDue" class="{{task.icon}} fa-5x card-img overdue" aria-hidden="true"></i>
<i ng-if="!task.finished && !task.isOverDue" class="{{task.icon}} fa-5x card-img pending" aria-hidden="true"></i>
<div class="card-content">
<h4>
<!--{{::task.short_description}}-->
<a ng-click="">{{::task.short_description}}</a>
</h4>
<span ng-if="!task.finished">
<span class="text-normal" ng-if="task.due_date">${Due by} {{::task.due_date | date: 'mediumDate' }}
<span class="text-warning" ng-if="task.isOverDue"> (${Overdue})</span>
</span>
</span>
<span ng-if="task.finished" class="text-muted">${Completed at} {{::task.closed_at | date: 'mediumDate'}}</span>
</div>
<div>
<i alt="${Open}" ng-if="!task.finished && task.isOverDue" class="m-l-sm fa fa-square-o fa-2x overdue"></i>
<i alt="${Open}" ng-if="!task.finished && !task.isOverDue" class="m-l-sm fa fa-square-o fa-2x pending"></i>
<i alt="${Completed}" ng-if="task.finished" class="m-l-sm fa fa-check-square-o fa-2x finished"></i>
</div>
</div>
</div>
</div>
Try changing your first media query to this:
#media screen and (min-width: 480px) and (max-width: 1023.99px) {
...
}
.cards:nth-of-type(3n) and .cards:nth-of-type(even) seem to both be applied.
Should the "min-width: 480px" be "max-width: 480px"?
As the CSS is currently defined, once the screen hits the 1024px width, then both min-width conditions are enabled along with the applicable CSS definitions.
I'm using Bootstrap 3 and want to override the default margin-bottom when screen min-width is 768, for inline form groups belonging to a form identified by #filter. So I did:
#media screen and (min-width: 768px) {
#filter .form-inline .form-group {
margin-bottom: 4px;
}
}
But it doesn't work, even when I added important! on the rule.
However, it does work after I removed the #filter in selector:
#media screen and (min-width: 768px) {
.form-inline .form-group {
margin-bottom: 4px;
}
}
That's really weird! I'm sure and tested that #filter can select the form. Can anyone tell me why?
The piece of code in Bootstrap I want to override is:
#media (min-width: 768px) {
.form-inline .form-group {
display: inline-block;
margin-bottom: 0;
vertical-align: middle;
}
...
}
But I only want to override this for the form #filter
The HTML code for the form is:
<form class="form-inline" id="filter" method="GET" action="<%= url("/blogs", false) %>">
<div class="form-group">
<label for="id" class="control-label">ID</label>
<input class="form-control" id="id" name="id" value="<%= params[:id] %>" />
</div>
<div class="form-group">
<label for="user_id" class="control-label">UID</label>
<input class="form-control" id="user_id" name="user_id" value="<%= params[:user_id] %>" />
</div>
...
<button type="submit" class="btn btn-default">Filter</button>
</form>
You are using the wrong selector #filter .form-inline. This means that .form-inline is the child of #filter which is incorrect.
What you need is #filter.form-inline which is a multi-selector. See Multiple Class / ID and Class Selectors
.small_only {
display: block;
}
.large_only {
display: none;
}
/* === Media Queries === */
// Extra large devices (large desktops, 1200px and up)
#media (min-width: 1200px) {
.small_only {
display: none;
}
.large_only {
display: block;
}
}
<div class="container">
<div class="row">
<div class="col-lg-12 col-xs-12">
<div class="small_only">
<h1>SMALL</h1>
</div>
<div class="large_only">
<h1>This should only be visible in large windows</h1>
</div>
</div>
</div>
</div>
Problem: The output contains only the word "SMALL" no matter how wide the screen is.
I feel like I'm missing something obvious, but for the life of me I can't figure out what it is.
Don't use // for comments in CSS..
Use /*..*/
http://www.codeply.com/go/uMSHCzymw3
.small_only {
display: block;
}
.large_only {
display: none;
}
/* === Media Queries === */
/* Extra large devices (large desktops, 1200px and up) */
#media (min-width: 1200px) {
.small_only {
display: none;
}
.large_only {
display: block;
}
}
EDIT
Codeply's CSS compiler which uses ACE editor picked it up..
I am trying to make an existing website responsive. I have an issue when the browser window gets to a certain size the links within the containing div start flowing outside of the div. If I remove the ".main_navigation a {white-space:nowrap;}" its ok but I need this to stop owrd going on new lines. Any suggestions?
.search {width:260px;height:30px;padding:10px 0 0 10px;text-align:left;float:left;}
.main_navigation {width:700px;min-height:20px;padding:10px 10px 10px 0;text-align:right;float:left;}.main_navigation a {font:10px/20px Tahoma, sans-serif;padding:4px 8px;text-decoration:none;color:#999999;border-radius:5px;-moz-border-radius:5px;}.main_navigation a:hover {color:#eeeeee;background:#999999;}
#media screen and (max-width: 580px){
.c_main {border:2px solid blue;max-width:580px}
.search_button {padding:3px 1px;}
.main_navigation {width:50%;}
}
#media screen and (max-width: 980px){
.search {width:28%;}
.main_navigation {width:70%;padding-left:0;padding-right:0;margin-right:0;float:right;}
.main_navigation a {white-space:nowrap;}
}
<div class="search">
<form method="get"><input id="txtQuickSearch" name="txtQuickSearch" type="text" value="search" /><input type="submit" value="search" class="search_button" /></form>
</div>
<span CLASS="icon-menu-2"></span>
<div class="main_navigation">
HomeBasketContactnew page
test external linksanother link
My AccountSign In
</div>
this is missing:
.main_navigation a {
display: inline-block;
}
You can use 2 different ways and test it on http://jsfiddle.net/ for example.
First way is:
.main_navigation a { display: block; float: left; }
Second way is:
.main_navigation { overflow: hidden; white-space: nowrap; }