What would be the best way to write this old CSS using LESS?
.paginationContainerTop {width:100%; margin-bottom:10px;}
.paginationContainerTop .paginationNav {float:right; text-align:right;}
.paginationContainerBottom {width:100%; margin-top:10px;}
.paginationContainerBottom .paginationNav {float:right; text-align:right;}
Based on my understanding, it would be something like:
.paginationNav {
float: right;
text-align: right;
}
.paginationContainerTop {
margin-bottom: 10px;
.paginationNav;
}
.paginationContainerBottom {
margin-top: 10px;
.paginationNav;
}
You don't need to nest .paginationNav; as a mixin inside your other divs.
Tom is right, it seems Top/Bottom should be IDs, and might not even be necessary? I'm imagining your HTML to look something like this:
<div id="header">
<div id="paginationNavTop">
<div id="paginationNav">[nav stuff]</div
</div>
</div>
[body stuff]
<div id="footer">
<div id="paginationNavBottom">
<div id="paginationNav">[nav stuff styled differently]</div
</div>
</div>
If that's the case, you could write this as your CSS:
.paginationNav {float: right; text-align: right;}
#header .paginationNav {margin-bottom: 10px;}
#footer .paginationNav {margin-top: 10px;}
instead of having Top and Bottom specific styles.
In LESS, you could nest the code like this:
.paginationNav {float: right; text-align: right;}
#header {
.paginationNav {margin-bottom: 10px;}
}
#footer {
.paginationNav {margin-top: 10px;}
}
The simple answer is
.paginationContainerTop, .paginationContainerBottom {width:100%;}
.paginationNav {float:right; text-align:right;}
.paginationContainerTop {margin-bottom:10px;}
.paginationContainerBottom {margin-top:10px;}
but that's doing you a disservice. It looks like you're using classes for what should be IDs. If I'm reading your code correctly, you probably want to break the shared properties out into classes and then use IDs (#paginationContainerTop instead of .paginationContainerTop) for the properties that are specific to individual elements. However, in this case you're specifying a property (width: 100%) that is the default unless it inherits something you've changed, so the CSS can be further trimmed to:
.paginationNav {float:right; text-align:right;}
.paginationContainerTop {margin-bottom:10px;}
.paginationContainerBottom {margin-top:10px;}
Also note that I've taken away the .paginationContainerTop/Bottom qualification from your .paginationNav styles: unless you need to override something or this will create a conflict, there's no need to specify an inheritance chain.
.paginationContainerTop {
width: 100%;
margin-bottom: 10px;
.paginationNav {
float: right;
text-align: right;
}
}
.paginationContainerBottom {
width: 100%;
margin-top: 10px;
.paginationNav {
float: right;
text-align: right;
}
}
i just used this tool to convert your css to less:
http://beautifytools.com/css-to-less-converter.php
hope this helps :)
Related
I have tried using a vuetify class based on breakpoint it worked
<v-app :class="{'yellow': !$vuetify.breakpoint.xs}">
I have a class named pagemargin in a vue file
But when I use this class it is not working, as in the following case
<v-app :class="{'pagemargin': !$vuetify.breakpoint.xs}">
why is it not working?
<style >
.pagemargin{
margin-right: 100px;
margin-left: 100px;
color: red;
}
</style>
Add !important to your styles. Vuetify adds its default style to the whole v-app so you need to override it.
.pagemargin{
margin-right: 100px !important;
margin-left: 100px !important;
color: red !important;
}
Using !important might work, but in long term as your application gets bigger, it could be costly. You should instead, solve this by providing a CSS that has a higher specificity than that of Vuetify. I provide you with an example:
<template>
<div class="my-div">
<v-btn :class="{'my-padding': !$vuetify.breakpoint.xs}" tile outlined color="success">
View
</v-btn>
</div>
</template>
<style>
/* this wont work */
.my-div .my-padding {
padding-right: 200px;
padding-left: 200px;
}
/* this works */
.my-div .v-btn.my-padding {
padding-right: 200px;
padding-left: 200px;
}
</style>
<style scoped>
/* this also works */
.my-div .my-padding {
padding-right: 200px;
padding-left: 200px;
}
</style>
You can read more about specificity here.
I would like to have an underline under my header, with the width of a bottom-border to put it simple.
However, I did not find how to extend the width/length of my underline.
Pay attention: in my case I cannot use a borderbottom. This solution does not work in my case.
<h1 id="hcomp"><img src="exp.png"/>Comp</h1>
The only solution would be to add spaces until i reach the width of my page:
<h1 id="hcomp"><img src="exp.png"/>Comp
</h1>
Solved.
<h1 id="hcomp"><img src="exp.png"/>Comp <hr class="hrstyle"></h1>
Css :
.hrstyle
{
border-top: 5px solid rgb(114, 159, 207);
margin-left: 0.6cm;
margin-top:0.05cm;
border-left: none;
border-right: none;
border-bottom: none;
}
I am having trouble centering my navigation bar, I have tried display:inline-block and then align center like most posts suggest but it doesn't seem to be working.
HTML:
<!--Navigation-->
<div class="band navigation">
<nav class="container primary">
<div class="sixteen columns">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Projects</li>
<li>Contact Us</li>
</ul>
</div>
</nav>
</div>
CSS:
nav.primary{
display: table;
margin: 0 auto;
}
nav.primary ul, nav.primary ul li {
margin: 0px;
}
nav.primary select {
display: none;
width: 100%;
height: 28px;
margin: 21px 0;
}
nav.primary ul li {
display: inline;
float: left;
position: relative;
}
nav.primary ul li a {
display: inline-block;
line-height: 49px;
padding: 0 14px;
color: white;
text-transform: uppercase;
text-decoration: none;
font-weight: bold;
letter-spacing: 0.08em;
background: ##999999;
}
nav.primary ul li a:hover {
background: #2ecc71;
cursor: pointer;
}
Ok finally got it:
nav.primary ul li {
display: inline;
float: left; <---
position: relative;
Remove the float: left;
Since the navigation is the full width of the containing div, there is no need to mess with floats, the list items will line up with just display: inline;
I tried something else that works... It seems to work better than trying to build in something custom thus far in my experience with Skeleton... Although it produces a bit less pretty markup for the HTML, the rigidity of the final result works for me. Here is my code so that you can see what I did to achieve the desired effect:
<div class="row">
<div class="two columns offset-by-three">
Portfolio
</div>
<div class="two columns">
About
</div>
<div class="two columns">
Contact
</div>
</div>
What you can see here is that the skeleton framework allows for the columns to operate naturally and restack at lower resolutions without any extra code. The only tricky part really is setting up the offset on the left most item.
Have you tried nav.primary ul {text-align: center;}
As well as keeping the left/right margins to auto, this worked for me when I was using the skeleton framework.
I'm following the book http://pragprog.com/book/rails4/agile-web-development-with-rails and my scss files aren't working.
The css file is this one:
.store {
h1 {
margin: 0;
padding-bottom: 0.5em;
font: 150% sans-serif;
color: #226;
border-bottom: 3px dotted #77d;
}
/* An entry in the store catalog */
.entry {
overflow: auto;
margin-top: 1em;
border-bottom: 1px dotted #77d;
min-height: 100px;
img {
width: 80px;
margin-right: 5px;
margin-bottom: 5px;
position: absolute;
}
h3 {
font-size: 120%;
font-family: sans-serif;
margin-left: 100px;
margin-top: 0;
margin-bottom: 2px;
color: #227;
}
p, div.price_line {
margin-left: 100px;
margin-top: 0.5em;
margin-bottom: 0.8em;
}
.price {
color: #44a;
font-weight: bold;
margin-right: 3em;
}
}
}
and the html file the following:
<% if notice %>
<p id="notice"><%= notice %></p>
<% end %>
<h1>Your Pragmatic Catalog</h1>
<% #products.each do |product| %>
<div class="entry">
<%= image_tag(product.image_url) %>
<h3><%= product.title %></h3>
<p><%= sanitize(product.description) %></p>
<div class="price_line">
<span class="price"><%= product.price %></span>
</div>
</div>
<% end %>
The CSS is loading properly, but not being applied. However if add a surrounding div with the class "store" it works. The book doesn't refer this situation, and I believe it should "automatically" apply the style, right?
Thanks.
**EDIT********
I found the problem. For those who may encounter the same issue, check the file:
app/assets/views/layouts/application.html.erb
body tag should have the following code:
<body class="<%= controller.controller_name %>">
Great that you found out the solution. But im trying to explain what happened behind the scene.
The way you are using the css is not a general convention. This facility comes with some additional gem. Check this link https://stackoverflow.com/a/4564922/1160106. With these gems you are able to design your css more DRY way.
General Convention
if you want to apply style to the following h1 element
# Here "store" class is the parent element of "h1"
<div class="store">
<h1> some text </h1>
</div>
Will require following way of css
#Here also "store" is written before "h1"
.store h1
{
#some designs
}
Whats happening in your case?
Probably you are maintaining controller wise css files. And presuming that you have a stores_controller. Thats why the classes for your stores_controller is encapsulated in .store {} block. Like
.store {
h3 {font-size: 120%;}
}
So it is clear that your h3 elements require a parent element having store class. And you are doing so by adding class="<%= controller.controller_name %>" with your body tag. Undoubtedly the <body> tag is parent of all following nodes. Now when you are hitting stores_controller it sets class="store" and your styles are working.
The approach is really DRY and recommendable.
As per your code all the styling is between the .store { } block, so it will not reflect as long as you surrounding div with the class "store"
For example
.store {
h3 {
font-size: 120%;
font-family: sans-serif;
margin-left: 100px;
}
}
is same as
.store h3 {
font-size: 120%;
font-family: sans-serif;
margin-left: 100px;
margin-top: 0;
margin-bottom: 2px;
color: #227;
}
I have a dashboard in which I'd like a scrolling ticker. (We'll know if the UI sucks or not once it's been running on the wall for a while.) Because this is a specific purpose dashboard, we can assume a recent WebKit in our markup and use even the latest CSS3 markup if it's implemented.
This is some exemplary markup, but we're free to change it as needed, although I'd prefer to keep it relatively semantic if possible:
<div class="ticker">
<div class="itemDiv">
<img src="x">
<div class="itemBodyDiv">
<span>Upper Box</span>
<span>Lorem ipsum dolor sit amet</span>
<span>Lower Box has longer text</span>
</div>
</div>
</div>
This is the layout I'd like to achieve:
The outer solid black line is a div. The dashed line is a div that represents an individual item in the ticker. Items will scroll right-to-left using -webkit-marquee. The main body of the ticker item is the lorem ipsum text, which needs overflow-x set to cause the marquee behavior. The main body should be text-align: middle.
The problem I'm having is in finding suitable CSS markup to describe the position of the Upper Box and Lower Box. I've tried several permutations of display: inline and inline-block that didn't work. They either ruined the marquee behavior or moved the main body over. It seems that they need to be pulled out of the normal box model, but can't be absolute since they wouldn't have the marquee behavior. It seems like there should be some sort of relative positioning that is outside of the box model flow that doesn't preserve normal flow spacing that would handle cases like this, but I'm not finding it amid the many drafts of the many revisions of CSS and certainly not among the cargo cult of Google search results.
By request, this is my current non-working CSS at the state of my last experiment:
.itemDiv {
display: inline;
vertical-align: middle;
}
.itemDiv > img {
margin: 10px 10px 10px 30px;
vertical-align: middle;
height: 48px;
width: 48px;
/* border: 1px solid red; */
}
.itemBodyDiv {
display: inline;
vertical-align: middle;
}
.itemDiv span:nth-child(1) {
font-size: small;
clear:left;
vertical-align: top;
color: green;
}
.itemDiv span:nth-child(2) {
font-size: x-large;
vertical-align: middle;
color: white;
}
.itemDiv span:nth-child(3) {
font-size: smaller;
vertical-align: bottom;
color: gray;
}
Any suggestions?
You should wrap the entire scrolling message in a a div with its position set to relative. That way, you're free to absolutely position elements inside of the message absolutely while not breaking the marquee behavior:
.message
{
position: relative;
}
.upper-box
{
position: absolute;
top: 5px;
left: 10px;
}
.lower-box
{
position: absolute;
bottom: 5px;
left: 10px;
}