I want to make a simple 3 columns / 3 rows grid with Susy 2 like :
1 2 3
4 5 6
7 8 9
But the blocks are floating in a buggy and heretic order.
You can have a look :
http://img.spheerys.fr/images/2015/01/05/bug-susy.jpg
Here my HTML Markup :
<article class="block">1</article>
<article class="block">2</article>
<article class="block">3</article>
<article class="block">4</article>
<article class="block">5</article>
<article class="block">6</article>
<article class="block">7</article>
<article class="block">8</article>
<article class="block">9</article>
Here my Susy map :
$susy: (
global-box-sizing: border-box,
use-custom: (
rem: true
),
columns: 12,
column-width: 4em,
gutters: 1/4
);
And finally, my Sass :
.block
+span(4 of 12)
&:nth-child(3n)
+last
+break
What's going wrong ?
:nth-child counts all sibling elements. So :nth-child(3n) doesn't just apply to every 3rd .block, it applies to every 3rd sibling that is also .block. The best solution when using :nth-child is to wrap all your list items in their own parent, without other siblings.
Susy also provides a shortcut to creating this sort of gallery layout...
html:
<!-- wrap all your blocks in a div -->
<div>
<article class="block">1</article>
<article class="block">2</article>
<article class="block">3</article>
<article class="block">4</article>
<!-- more blocks... -->
</div>
sass:
.block
+gallery(4 of 12)
That should be all you need.
Related
Using Thymeleaf th:each loop, whitespace is removed (or can't be added).
Thymeleaf code:
<div>
</div>
I expected:
<div>
Link 1
Link 2
Link 3
Link 4
Link 5
</div>
but html rendered below.
<div>Link 1Link 2Link 3Link 4Link 5</div>
How to add whitespace (in html file new line) using Thymeleaf th:each?
My Thymeleaf version is 3.0.12.RELEASE
If you want the links to be arranged horizontally with a single white space between them (as opposed to arranging them vertically using display:block) then you can use the Thymeleaf synthetic <th:block> element (documented here):
<div>
<th:block th:each="item : ${items}">
</th:block>
</div>
This will give you the same layout as you show in your question, when you run the first code snippet.
Update:
You can also use <span> instead of <th:block>, if you prefer:
<div>
<span th:each="item : ${items}">
</span>
</div>
This will give you the same end result (links arranged horizontally with a space between them), but the HTML generated to produce this layout will, of course, be slightly different.
Using xpath, can I get 2 results out of a page at a time? For example, using xpath I can get the first img element:
xpath='//div[#class="forecast-element graphic-box"]/img
...and the next sibling class="forecast-element".
I tried "and" without success:
xpath='//div[#class="forecast-element graphic-box"]/img and //div[#class="forecast-element"]'
also:
xpath='//div[#class="forecast-element graphic-box"]/img and following-sibling:://div[#class="forecast-element graphic-box"]'
I have this html:
<div class='forecast-element graphic-box ' style="background-image:url('/assets/images/forecast/BluePattern.png');">
<h4 style="color: #FFF;">AVALANCHE DANGER <span style="margin-left: 60px;"> MORNING </span><span style="margin-left: 210px;"> AFTERNOON</span></h4>
<img src="/images/forecast/2014-11-23_teton_hazard.gif" alt="Teton Area avalanche hazard rating for 11/23/2014" />
<div style='margin: 2px auto;'><a href="/assets/pdfs/North%20American%20Danger%20Scale.pdf" style='font-size: 14px; color: #CCC;'>View full danger scale definitions</a>
</div>
<a href="/assets/pdfs/North%20American%20Danger%20Scale.pdf" style='font-size: 14px;'>
<img src="/assets/images/forecast/DangerScale.png" style="margin-left: 150px; margin-top: 5px;" alt='Avalanche danger scale ratings'>
</a>
</div>
<div class='forecast-element'>
<h3 style='margin-bottom: 8px;'>GENERAL AVALANCHE ADVISORY</h3>
Moderate to heavy snowfall combined with strong southwesterly to northwesterly ridgetop winds have created unstable avalanche conditions. New wind slabs have developed at the mid and upper elevations. Snowfall over the past 24 hours has also added weight to existing weak layers near the base of the snowpack. Early season snowfall can easily cloud people’s judgment. Cautious route finding and conservative decision making will be essential for safe travel in avalanche terrain today.</div>
I would like to use following-sibling, as the item is right after the graphic-box element and there are other forecast-elements in the html above and below. BTW, I am using YQL if that makes a difference...
Ideally the results would be (psuedo here):
xpath imgsrc = "/images/forecast/2014-11-23_teton_hazard.gif"
xpath text = "GENERAL AVALANCHE
ADVISORY Moderate to heavy snowfall combined with strong
southwesterly to northwesterly........"
Thanks!
The correct syntax for selecting multiple nodes is |
Try this:
//div[#class="forecast-element graphic-box"]/img | //div[#class="forecast-element"]
As you mentioned, these are two separate query elements. In order to select following elements simply do this
//div[#class="forecast-element graphic-box"]/img | //div[#class="forecast-element graphic-box"]/following-sibling::div[#class="forecast-element"]
In some xpath parsers, this will also work:
//div[#class="forecast-element graphic-box"]/(img|following-sibling::div[#class="forecast-element"])
Trying to deal with irregular content in div elements. Namely what comes after the h3 titles. There is no set content under the h3 headings. However, I need to associate whatever text is there with the heading. There could be a ul or just a span or both. The main thing is not combining all the text under the h3 headings.
I have been able to navigate to my div using the .css operator. Each div contains one or more of 4 h3 headings followed by a comment or a list if there is more than one comment.
How can I separate whatever follows a h3 tag ending before the next tag (if there is one)?
You can see a sample of the div I'm working with here (I can grab whatever is between the h2 because its the same for every div):
<div class="inspection_container">
<h2 class="inspection_date_title">
<div class="calendar_list">
<span>Mar</span><strong>4</strong>
</div>Routine Inspection<small>Inspected Mar. 4, 2014</small>
</h2>
<h3>Actions taken by inspector</h3>
<ul>
<li class="Comment">
<strong>Consultation / Technical Assistance</strong><p>Instructions are given to the owner/operator to assist them with taking the proper actions to meet regulations.</p>
</li>
</ul>
</div>
<div class="inspection_container">
<h2 class="inspection_date_title">
<div class="calendar_list">
<span>Sep</span><strong>4</strong>
</div>Re-inspection<small>Inspected Sep. 4, 2013</small>
</h2>
<h3>Not in compliance</h3>
<ul>
<li class="X">
<strong>Premise is clean/sanitary</strong><p>Food premise is to be maintained in a clean and sanitary condition.</p>
</li>
</ul>
<h3>Actions taken by inspector</h3>
<ul>
<li class="Comment">
<strong>Consultation / Technical Assistance</strong><p>Instructions are given to the owner/operator to assist them with taking the proper actions to meet regulations.</p>
</li>
</ul>
</div>
<div class="inspection_container">
<h2 class="inspection_date_title">
<div class="calendar_list">
<span>Aug</span><strong>30</strong>
</div>Routine Inspection<small>Inspected Aug. 30, 2013</small>
</h2>
<h3>Not in compliance</h3>
<ul>
<li class="X">
<strong>Washrooms are cleaned regularly</strong><p>Washrooms are to be kept clean, sanitary, in good repair and must be supplied with liquid soap in a dispenser, single service/paper towels, cloth roller towel or hot air dryer and hot and cold running water.</p>
</li>
<li class="X">
<strong>Building interior is well-maintained</strong><p>Walls, floors and ceilings are to be maintained and in good repair.</p>
</li>
<li class="X">
<strong>Premise is clean/sanitary</strong><p>Food premise is to be maintained in a clean and sanitary condition.</p>
</li>
</ul>
<h3>Actions taken by inspector</h3>
<ul>
<li class="Comment">
<strong>Consultation / Technical Assistance</strong><p>Instructions are given to the owner/operator to assist them with taking the proper actions to meet regulations.</p>
</li>
</ul>
</div>
Provided that:
You only have intertwined h3 and ul elements till the end of the wrapping div
no other element can appear in this structure instead of ul
no other element can appear in this structure instead of h3
and that your example is representative, this should do the trick.
//ul[count(following-sibling::h3) = count(following-sibling::ul)]
If you have other elements in the same place as the ul but there is always only one between the h3s, you can use this expression
//ul[count(following-sibling::h3) = count(following-sibling::*[not(local-name() = 'h3')])]
As for grouping the h3 elements and the ul elements following them immediately, I don't think this is feasible in XPath alone. You'll need to do this in Ruby. I suggest searching for the div elements and parsing them imperatively, while counting the nodes and grouping the odd and even h3s and uls together
I want to display a div alongside a portait picture, but I want the div to fill all the remaining gap between the picture's right side and the edge of the webpage.
Here is the scheme:
xxxxxxxxxxxx
x| P || |x
x| i || |x
x| c || D |x
x| t || i |x
x| u || v |x
x| r || |x
x| e || |x
xxxxxxxxxxxx
Where xxx are the edges of the webpage.
I am not able to get the picture size, because I use the same webpage structure for many other portrait pictures, with not the same ratio, height/width....
What I have been able to do is:
<body>
<img style="float:left; height:100%;" src="portraitpictures_url" >
<div style="width: 100%;background:blue;color:white; border-radius:10px;" >
<p>The div text</p>
</div>
</body>
But this not what I want to have, because my div has a 100% width and so my div border is hiding partly behind the picture.
If I put my <img> tag between <div> and </div>, my picture's height overflows from the body and so is not "screen height".
I am quite sure, it is possible to do better, but here I am stuck...
Here is the full code in Django template style:
<body>
<img style="float:left; height:calc(100% - 45px);" src="{{ MEDIA_URL }}{{ A.picture.name }}" >
<div style=" width: 100%; margin-top: 2%;background:red ;color:blue; border-radius:10px;" >
<p>The div text</p>
</div>
</body>
You should add width:auto to your second div and set overflow to hidden ,like I've done here : http://jsfiddle.net/h5CU3/ . You can also add horizontal margin to the first block (margin :0 5px 0 0) in case you don't want it to look merged.
<body >
<div style="float:left; height:100%;">
<img src="portraitpictures_url" >
</div>
<div style="overflow:hidden;width:auto;overflow:hidden;background:blue;color:white; border- radius:10px;" >
<p>The div text</p>
</div>
</body>
Just add float:left to your div as well.
Does this do what you want? (the left margin should be set to the width of the img.
<body>
<div style="width:100%;">
<img style="float:left; height:100%;" src="portraitpictures_url">
<div style="margin-left:100px;background:blue;color:white; border-radius:10px;">
<p>The div text</p>
</div>
</div>
</body>
you need to add style
overflow: hidden;
Flexbox can do the trick, I have not tried this out yet, but I have read about it.
I'm sure this is what you are looking for.
Flexbox is an ongoing project that makes it easy to place 's on the exact spot you want it to be.
It has a built in function to fill up remaining space automaticaly.
http://learnlayout.com/flexbox.html (source: http://learnlayout.com/)
Is it possible to nest grids with Singularity?
Here is my setup:
$break: 500px;
$break1: 700px;
$break2: 900px;
$break3: 1200px;
$grids: 3;
$grids: add-grid(6 at $break);
$grids: add-grid(12 at $break1);
$grids: add-grid(2 8 2 at $break2);
$grids: add-grid(3 6 1 1 1 at $break3);
$gutters: 1/3;
$gutters: add-gutter(.25 at 900px);
$output: 'isolation';
The current context I'm asking about is inside $break3.
I would like to have the following grid structure.
I realise the below isn't right it is just there as a demonstration as to the grid structure I'd like to have. I have tried using functions to output the correct widths but have had no luck, but that is probably because I was doing it all wrong.
HTML structure:
<div class="container">
<div class="1">
<div class="1-a"></div>
<div class="1-b"></div>
<div class="1-c"></div>
<div class="1-d"></div>
</div>
<div class="2"></div>
</div>
SCSS
div.1: #include grid-span(4, 2);
div.1-a nested in div1 and span the first column of 4
div.1-b nested in div1 and span the last 3 columns of 4
div.1-c nested in div1 and span the last 3 columns of 4 stacked below 1-b
div.1-d nested in div1 and span the last 3 columns of 4 stacked below 1-c
div.2: #include grid-span(1, 1);
Of course you can! $grids only deals with your main grid context, but if you would like to change your grid context, you can either override your grid context through grid-span or you can do it through the layout mixin.
Also take a look at this related issue and answer.