Gear 2 (SM-380) doesn't support #media screen queries - css

I use the following media query in CSS and it works fine with Gear 2 Neo (SM-R381), but it doesn't work with an older Gear 2 (SM-R380). Do you have any idea why? Probably it's related to a difference in API level supported by these two devices? Any pointers are appreciated. Googling didn't help so far.
The styles are completely ignored by SM-R380, while honored by SM-R381.
#media screen and (max-width: 320px) {
/*
.ui-header {
top: 0;
height: 46px;
padding: 0;
border: 0;
}
.ui-footer {
border: 0;
padding: 0;
position: fixed;
width: 100%;
bottom: 0;
left: 0;
}
.ui-header > button, .ui-footer > button {
height: 46px;
padding: 0;
line-height: 48px;
}
footer.ui-footer {
height: 46px;
}
*/
.icon-title {
max-width:250px;
}
.icon-title-menu {
max-width:200px;
}
. digit {
width: 23px;
height: 34px;
float: left;
margin-right: 1px;
margin-left: 1px;
background-size: 100%;
background-repeat: no-repeat;
}
.colon {
background-image: url(../img/14x51/colon.png);
width: 8px;
height: 40px;
}
.token {
margin-left:auto;
margin-right:auto;
margin-top:5%;
width:154px;
height:auto;
}
.time {
margin-left:auto;
margin-right:auto;
margin-top:5%;
width:170px;
height:auto;
}
.pb {
margin-left:auto;
margin-right:auto;
margin-top:27%;
width:64px;
height:64px;
background-size: 100%;"
background-repeat: no-repeat;
}
}

After going back and forth with this and not getting a solution to make #media working on Gear 2 (SM-R380), I found a way around:
Created two stylesheets- one for 320x320 screen, another for 360x480
Added the following code to index.html just before </head> tag:
<script type="text/javascript">
function setStyle(kb) {
var link = document.createElement( "link" );
link.href = kb?"./css/style.css":"./css/style320.css";
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen";
document.getElementsByTagName( "head" )[0].appendChild( link );
}
tizen.systeminfo.getPropertyValue("DISPLAY",
function (disp) {
if (disp.resolutionWidth <= 320)
setStyle(false);
else
setStyle(true);
},
function (err) {console.log("Can't read display props: " + err.message); setStyle(false);}
);
</script>
Now it seems to be working and appstore has finally accepted the application.

Related

How to override all classes within in a media query?

I am building a custom .css, but I do not know, how to override a bunch of classes within a media query with "nothing". Means, I do not want this in my output, but also I don't want to delete this from the css as it needs to stay original. I also don't want to copy the whole bunch of classes and write "none" or "unset" behind every single attribute. Is there any solution for this. Thanks a lot.
/*original.css*/
#media only screen and (max-device-width: 720px) {
ol.accord li {
width: 100%;
}
.content {
height: 149px;
width: 50%;
}
ol.accord li h3 {
height: 30px;
width: 100%;
margin: 0;
border-right: none;
border-bottom: 1px solid #fff;
padding: 7px 10px;
}
}
/*custom.css*/
/*here should be nothing like it wouldn´t even exist in the original*/
You can write as many classes in the media query within the parenthesis.
Here is an example for this
Just define the class above and change as per your requirement as per screen size.
.custom_class1 {
height : 1px;
}
#media only screen and (max-device-width: 720px) {
ol.accord li {
width: 100%;
}
.content {
height: 149px;
width: 50%;
}
ol.accord li h3 {
height: 30px;
width: 100%;
margin: 0;
border-right: none;
border-bottom: 1px solid #fff;
padding: 7px 10px;
}
.custom_class1 {
height:70px;
}
.custom_class2 {
height:70px;
}
}

Apply a property to a class but not to its :before and :after

I'm trying to create a stepper in the form of arrow (using angular / css mostly). Let's start with this codepen. What I want to do now, is to center the status name in the middle of the arrow.
The straight-forward idea I had was to do something around those lines to apply the text-align center property.
.block-head {
/* rest of the class css */
text-align: center;
}
.block-head:before {
/* rest of the class css */
text-align: left;
}
.block-head:after {
/* rest of the class css */
text-align: left;
}
Problem is this is not working. I tried setting the text align property to center on the block-text class aswell, but it's not working either...
How can I apply the text-align:center property to my class but not to it's :before & :after ? And if it's not possible, how should I change my code to keep the current design and have the text centered ?
You can use flexbox properties for this.
Add display: flex; and justify-content: center to block-text
codepen
Multiple ways are there to get it . Try like this. This is a quick fix by giving your .block-text margin-left:50%;
function ctrl($scope){
// those variable are passed as param to the directive
$scope.selectedKey = 2
$scope.elements =
[
{
name: "Status 1",
key: 1,
description: "description status 1"
},
{
name: "Status 2",
key: 2,
description: "description status 2"
},
{
name: "Status 3",
key: 3,
description: "description status 3"
},
{
name: "Status 4",
key: 4,
description: "description status 4"
}
]
$scope.colors =
{
current: "lightblue",
success: "lightgreen",
disable: "lightgrey"
}
$scope.widthCalc = ($scope.elements.length - 1) * 26
$scope.getColor = function($index) {
if ($scope.elements[$index].key === $scope.selectedKey)
return $scope.colors['current']
if ($scope.elements[$index].key < $scope.selectedKey)
return $scope.colors['success']
if ($scope.elements[$index].key > $scope.selectedKey)
return $scope.colors['disable']
}
}
.block-container {
width: auto;
padding-top: 4px;
padding-right: 8px;
padding-left: 8px;
margin-bottom: -10px;
}
.block-head {
background-color: #4D81BF;
height: 20px;
line-height: 20px;
display: inline-block;
position: relative;
width:22px;
margin-right:4px;
margin-bottom: -5px;
}
.block-text {
color: black;
font-size: 14px;
margin-left: 50%;
}
.block-head:before {
color: #FAFAFA;
border-left: 10px solid;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
display: inline-block;
content: '';
z-index:1;
position: absolute;
top:0;
}
.block-head:after {
color: inherit;
z-index:2;
border-left: 10px solid;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
display: inline-block;
content: '';
position: absolute;
right: -10px;
top:0;
}
.block-head-first {
margin-left:0px !important;
}
.block-head-last {
margin-right:0px;
}
.block-head-first:before {
color: #FAFAFA;
border-left: 0;
border-top: 0;
border-bottom: 0;
display: inline-block;
content: '';
z-index:1;
position: absolute;
top:0;
}
.block-head-last:after {
color: #4D81BF;
border-left: 0;
border-top: 0;
border-bottom: 0;
display: inline-block;
content: '';
z-index:1;
position: absolute;
top:0;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!DOCTYPE html>
<html ng-app>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<meta charset=utf-8 />
<title>Angular JS Demo</title>
</head>
<body ng-controller="ctrl">
<div class="block-container">
<div ng-repeat="element in elements"
class="block-head"
ng-class="{'block-head-first': $first, 'block-head-last': $last}"
ng-style="{'width' : selectedKey === element.key ? 'calc(100% - ' + widthCalc + 'px)' : '',
'background-color': getColor($index),
'color': getColor($index)}">
<span class="block-text" ng-if="selectedKey === element.key">{{element.name}}</span>
</div>
</div>
</body>
</html>
.block-head {
text-align: center;
}
.block-head:before {
left: 0px;
}
Take a look at my codepen:.
The fix was relatively simple.
You were trying to change the text-align of the outer element and I changed it for the inner element:
block-text {
color: black;
font-size: 14px;
padding-left: 24px;
display: inline-block;
width: 100%;
text-align: center;
}
I also changed from margin-left to padding-left to properly handle the width: 100%

LESS puts spaces in wrong places

So... I'am creating a small bootstrap and i want it efficiently done, so i've chose the LESS to do some job for me. And i found that LESS compiler puts spaces between classes when it is written like this:
div.cb {
input[type="text"] {
border: 1px #d9d9d9 solid;
height: 15px;
padding: 5px;
.large {
width: 250px;
}
.medium {
width: 150px;
}
.small {
width: 50px;
}
.fill {
width: 100%;
}
}
}
results in:
div.cb input[type="text"] {
border: 1px #d9d9d9 solid;
height: 15px;
padding: 5px;
}
div.cb input[type="text"] .large {
width: 250px;
}
div.cb input[type="text"] .medium {
width: 150px;
}
div.cb input[type="text"] .small {
width: 50px;
}
div.cb input[type="text"] .fill {
width: 100%;
}
and the gaps between the element and classes prevents in my browser (chrome) in the correct processing. Is there a way to have same or similar code in LESS and have right outputting CSS? Without those gaps...
With less you can reference the parent of a code block by using &
So this:
.class
{
.anotherClass
{
background: red;
}
}
Compiles to:
.class .anotherClass { background: red; }
Whereas this:
.class
{
&.anotherClass
{
background: red;
}
}
Compiles to this:
.class.anotherClass { background: red; }
I hope that makes the difference obvious

Inherit CSS class from separate file?

I have a class for a button:
.client-header button {
/*Properties*/
}
and a class to detect when the menu is open:
.client-menu-open {
/*Properties*/
}
I would like to change the button background based on whether or not the menu is open. I want something like this:
.client-header button .client-menu-open {
/*Properties*/
}
But the classes are in two different files, so it doesn't work. Is there any way to do this across different files?
Here is the code for the header index.css:
#import url('../menu/index.css');
.client-header {
position: absolute;
top: 0;
left: 0;
right: 0;
height: var(--header-height);
overflow: hidden;
border-bottom: 1px solid #7E7E7E;
background: #cccccc;
}
.client-header button {
float: left;
height: 100%;
border: none;
border-right: 1px solid var(--border-color);
border-radius: 0;
box-shadow: none;
line-height: 39px;
background-color: #444444;
color: #FFF;
}
.client-header button:hover {
background-color: #555555;
}
.client-header button:active {
background-color: #4E4E4E;
}
.client-header-caption {
float: left;
}
.client-header-title,
.client-header-subtitle {
margin-left: 10px;
}
.client-header-title {
line-height: 25px;
}
.client-header-subtitle {
font-size: 0.5rem;
line-height: 15px;
}
#media (min-width: 640px) {
.client-header-title,
.client-header-subtitle {
display: inline-block;
line-height: var(--header-height);
}
.client-header-title {
font-size: 1.5rem;
}
.client-header-subtitle {
font-size: 1rem;
}
}
.client-header .client-menu-open button {
background: #CCCCCC;
}
And here is the code for the menu index.css:
.client-menu {
position: absolute;
top: var(--header-height);
bottom: 0;
left: -var(--menu-width);
width: var(--menu-width);
border-right: 1px solid var(--border-color);
padding-bottom: var(--menu-footer-height);
overflow: hidden;
transition: left 0.2s;
}
.client-menu-open {
left: 0;
box-shadow: 0 0 30px var(--shadow-color);
background: #444444;
}
.client-menu-pinned {
box-shadow: none;
}
.client-menu-header {
height: var(--menu-header-height);
text-align: right;
background-color: #444444;
}
.client-menu-footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: var(--menu-footer-height);
text-align: right;
}
And the HTML structure is:
<header class="client-header">
<button class="client-header-menu-toggle"/>
</header>
<div class="client-menu"/>
You can use #import like so (in your primary CSS stylesheet):
#import url('external.css');
/* external.css above will be loaded */
Refer to this documentation: http://www.cssnewbie.com/css-import-rule/
Link to the other file and style .client-menu-open
if this is your html
<div class="client-menu-open"> <!-- this class is here only if the menu gets opened, else, this div has no class -->
stuff
stuff
<div class="client-header-button">
<button></button>
</div>
</div>
the correct syntax is the following
button {
background:red;
}
.client-menu-open button {
background:blue
}
The #import rule allows you to include external style sheets in your document. It is a way of creating a style sheet within your document, and then importing additional rules into the document.
To use the #import rule, type:
<style type="text/css">
#import url("import1.css");
#import url "import2.css";
</style>
For more info refer here https://developer.mozilla.org/en-US/docs/Web/CSS/#import
your CSS selector is incorrect, that's why it doesn't work. It has nothing to do with where CSS styles are defined.
.client-header button .client-menu-open will only select the following elements:
elements with class="client-menu-open"
which are children of button elements
which themselves are children of elements with class="client-header"
.
what you want, I think, is
button elements
which are children of elements having "class=client-header" AND "class=client-menu-open".
the proper selector for those elements would be .client-header.client-menu-open button.

Vertical alignment of Images inside DIV

I am retrieving a bulk images through response and I need to arrange them inside a div tag and all the images are placing one below the other but I need to arrange them vertical (i.e. side by side)
So how do I do that?
And I followed this tutorial but I can arrange only text?
http://phrogz.net/CSS/vertical-align/index.html
Can anyone suggest me the right way?
Here is my code:
$('#showfilelist').append("<div id=" + file.id + "><a href='uploads/" +
file.target_name + "' target='_blank' rel='gallery'><img src='thumbs/" +
file.target_name + "' border='0'/></a> </div>");
Here is what I'm getting the result
Plupload Css:
/*
Plupload
------------------------------------------------------------------- */
.plupload_button {cursor: pointer;}
.plupload_wrapper {
font: normal 11px Verdana,sans-serif;
width: 100%;
}
.plupload .plupload_container input {width: 98%;}
.plupload .plupload_filelist_footer {border-width: 1px 0 0 0}
.plupload .plupload_filelist_header {border-width: 0 0 1px 0}
div.plupload .plupload_file {border-width: 0 0 1px 0}
div.plupload div.plupload_header {border-width: 0 0 1px 0; position: relative;}
.plupload_file .ui-icon {
cursor:pointer;
}
.plupload_header_content {
background-image: url('../img/plupload.png');
background-repeat: no-repeat;
background-position: 8px center;
min-height: 56px;
padding-left: 60px;
position:relative;
}
.plupload_header_content_bw {background-image: url('../img/plupload-bw.png');}
.plupload_header_title {
font: normal 18px sans-serif;
padding: 6px 0 3px;
}
.plupload_header_text {font: normal 12px sans-serif;}
.plupload_filelist,
.plupload_filelist_content {
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
-moz-user-select:none;
-webkit-user-select:none;
user-select:none;
}
.plupload_cell {padding: 8px 6px;}
.plupload_file {
border-left: none;
border-right: none;
}
.plupload .ui-sortable-helper,
.plupload .ui-sortable .plupload_file {
cursor:move;
}
.plupload_scroll {
max-height: 180px;
min-height: 168px;
_height: 168px;
overflow-y: auto;
}
.plupload_file_size, .plupload_file_status {text-align: right;}
.plupload_file_size, .plupload_file_status {width: 52px;}
.plupload_file_action {width: 16px;}
.plupload_file_name {
overflow: hidden;
padding-left: 10px;
}
.plupload_file_rename {
width:95%;
}
.plupload_progress {width: 60px;}
.plupload_progress_container {padding: 1px;}
/* Floats */
.plupload_right {float: right;}
.plupload_left {float: left;}
.plupload_clear,.plupload_clearer {clear: both;}
.plupload_clearer, .plupload_progress_bar {
display: block;
font-size: 0;
line-height: 0;
}
.plupload_clearer {height: 0;}
/* Misc */
.plupload_hidden {display: none;}
.plupload_droptext {
background: transparent;
text-align: center;
vertical-align: middle;
border: 0;
line-height: 165px;
}
.plupload_buttons, .plupload_upload_status {float: left}
.plupload_message {
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
}
.plupload_message p {
padding:0.7em;
margin:0;
}
.plupload_message strong {
font-weight: bold;
}
plupload_message i {
font-style: italic;
}
.plupload_message p span.ui-icon {
float: left;
margin-right: 0.3em;
}
.plupload_header_content .ui-state-error,
.plupload_header_content .ui-state-highlight {
border:none;
}
.plupload_message_close {
position:absolute;
top:5px;
right:5px;
cursor:pointer;
}
.plupload .ui-sortable-placeholder {
height:35px;
}
I believe what you want is float: left; on your images.
Functioning example: http://jsfiddle.net/NeMDZ/2/ (Try moving the middle divider. Flexible layout is optional.)
The basic CSS:
div.imgContain {
overflow:hidden; /* Only necessary if you need to style the containing box.
Forces box to expand to content's height. */
}
div.imgContain img {
float:left;
}
All the other CSS is optional. Style at will.
img {
display: inline-box;
}
The images will set in the same line as long they fit there. Be very careful with padding and margin values.
Images are block-level elements by default, so you will need float: left on your images (or whatever element your image is contained in) if you want them to be side-by-side. If you want to start a new line, create a spacer element like:
.spacer {
clear: both;
}
and then add <div class="spacer"></div> where you want to break a line of images and start a new one. You may need other attributes on your spacer to work in old browsers.

Resources