/    Sign up×
Community /Pin to ProfileBookmark

Responsive grid

Hi,
I have a grid which look like this

“`
_____________________________
| nav | |
| list | logo |
|________________|__________|
| | |
| empty | text |
|________________|__________|
“`

The nav list is fixed to the left upper former, sticky. Always there when scrolling the mouse.

After respositivity should look like this

“`
____________
| logo |
| |
|__________|
| |
| navlist |
|__________|
| |
| text |
____________
| |
| |
|__________|
“`

The logo is fixed, nav list is scrolling.
VCan anybody help me?

to post a comment
CSSHTML

31 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumFeb 08.2022 — @Ashley128#1642294

I edited your posting in order to make the display more clear. Hope you agree.
Copy linkTweet thisAlerts:
@SempervivumFeb 08.2022 — @Ashley128#1642294

Check if this meets your requirements:
``<i>
</i>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;

&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;title&gt;Test Layout&lt;/title&gt;
&lt;style&gt;
body {
margin: 0;
}

* {
box-sizing: border-box;
}

#logo {
width: 100%;
position: sticky;
left: 0;
top: 0;
}

nav,
section {
padding: 0.5em;
}

@media (min-width: 600px) {
#logo {
width: 50%;
position: fixed;
left: 0;
top: 0;
}

nav,
section {
margin-left: 50%;
width: 50%;
}

}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;body&gt;
&lt;img id="logo" src="images/busleft.png"&gt;
&lt;nav&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;section&gt;
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua.
Shortened, large amount of text here.
&lt;/section&gt;
&lt;/body&gt;

&lt;/html&gt;<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 08.2022 — 
Hi,

It works. Thanks.
Copy linkTweet thisAlerts:
@SempervivumFeb 08.2022 — Alternative CSS, just flex layout, no `position</C>:
<CODE>
`<i>
</i> &lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;

&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
&lt;title&gt;Test Layout&lt;/title&gt;
&lt;style&gt;
html,
body {
height: 100%;
}

body {
margin: 0;
display: flex;
flex-direction: column;
}

#logo {
width: 100%;
}

nav,
section {
padding: 0.5em;
}

#wrapper {
overflow: auto;
}

@media (min-width: 600px) {
body {
flex-direction: row;
align-items: flex-start;
}

#logo {
flex: 1;
}

#wrapper {
flex: 1;
height: 100%;
}
}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;body&gt;
&lt;img id="logo" src="images/busleft.png"&gt;
&lt;div id="wrapper"&gt;
&lt;nav&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#"&gt;Page 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;section&gt;
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores
et earebum.
Shortened, large amount of text here.
&lt;/section&gt;
&lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 10.2022 — Thank. Very good.
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — Hi,

I have a problem here.

When I print out my web page, I will get all stuff including logo nav list etc. I do not want this printed. I just want the text outprinted, see picture above regarding grid on my page.

I tried using

@media print

but I do not get it right.

Please help
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — `@media print` is the correct approach. If it doesn't work for you, please post your attempt.
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — Hi,

This is my print.css file
``<i>
</i>@media print {

body {
text-align: center;
margin: 0;
color: #000;
background-color: #fff;
}
}<i>
</i>
`</CODE>
<HR>---------------------------</HR>
This is my index.html
<CODE>
`<i>
</i>&lt;body&gt;
&lt;div class="container"&gt;
&lt;div class="item1"&gt;
&lt;nav&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#" id="activePage"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="html/tourism.html"&gt;Tourism&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;/div&gt;

&lt;div class="item2"&gt;
&lt;img src="images/cropped-IMG_7105.jpg" /&gt;
&lt;h1&gt;AAA&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="item3"&gt;
&lt;/div&gt;

&lt;div class="item4"&gt;
&lt;article class="info"&gt;
&lt;h2&gt;Info&lt;/h2&gt;
&lt;/article&gt;

&lt;article class="news"&gt;
&lt;h2&gt;News&lt;/h2&gt;
&lt;h3&gt;Party&lt;/h3&gt;
&lt;p&gt;2019-04-06&lt;/p&gt;
&lt;p&gt;....&lt;/p&gt;
&lt;img src="images/party.jpg" /&gt;
&lt;img src="images/party2.jpg" /&gt;
&lt;/article&gt;

&lt;article class="fence"&gt;
&lt;h3&gt;...&lt;/h3&gt;
&lt;p&gt;2018-07-16&lt;/p&gt;
&lt;p&gt;....&lt;/p&gt;
&lt;img src="images/fence.jpg" /&gt;
&lt;img src="images/fence2.jpg" /&gt;
&lt;br&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc faucibus a pellentesque sit.
Ultrices gravida dictum fusce ut placerat orci nulla. Tempor orci eu lobortis elementum nibh tellus. Faucibus vitae aliquet nec ullamcorper sit. Vestibulum lorem sed risus ultricies tristique nulla. Pellentesque nec nam aliquam sem et.
Aenean sed adipiscing diam donec adipiscing tristique risus. Tortor condimentum lacinia quis vel eros donec ac odio. Integer enim neque volutpat ac tincidunt vitae semper quis lectus. Feugiat scelerisque varius morbi enim nunc faucibus.&lt;/p&gt;
&lt;p&gt;Nisl nisi scelerisque eu ultrices vitae auctor eu augue. Sapien pellentesque habitant morbi tristique senectus et netus et malesuada. Placerat vestibulum lectus mauris ultrices eros in. Pellentesque habitant morbi tristique senectus et netus.
Quam id leo in vitae turpis massa. Risus nec feugiat in fermentum posuere urna nec. Enim diam vulputate ut pharetra sit amet aliquam id. Vulputate sapien nec sagittis aliquam malesuada. Sit amet consectetur adipiscing elit ut aliquam.
Laoreet id donec ultrices tincidunt arcu. Ut eu sem integer vitae justo. Penatibus et magnis dis parturient montes. Aliquam purus sit amet luctus venenatis lectus magna fringilla. Odio tempor orci dapibus ultrices in iaculis nunc.
Vestibulum sed arcu non odio euismod lacinia at. Mauris sit amet massa vitae tortor condimentum lacinia. Faucibus scelerisque eleifend donec pretium. In est ante in nibh mauris cursus mattis molestie a.&lt;/p&gt;
&lt;/article&gt;
&lt;br&gt;&lt;br&gt;
&lt;/div&gt;
&lt;main&gt;
&lt;/main&gt;<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — I just want the text and figures in .item4 printed out on the paper for all webpages.
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — Try this:

Apply a class e. g. "noprint" to any element you do not want to be printed:
``<i>
</i> &lt;div class="item1 noprint"&gt;
&lt;nav&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#" id="activePage"&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="html/tourism.html"&gt;Tourism&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;/div&gt;<i>
</i>
`</CODE>
The parent is sufficient.<br/>
Then hide these elements while printing:
<CODE>
`<i>
</i>@media print {
.noprint {
display: none;
}
body {
text-align: center;
margin: 0;
color: #000;
background-color: #fff;
}
}<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — The layout on the screen is snrinked
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — Do you mean the layout in the printing preview?
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — <div class="item1 noprint">

<nav>

<ul>

<li><a href="#" id="activePage">Home</a></li>

<li><a href="html/tourism.html">Tourism</a></li>

</ul>

</nav>

</div>

this iwill also mbe printed out on the screen
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — This is my grid.css

.container {

display: grid;

grid-template-columns: 200px auto;

background-color: #8EDFCF;

}

.item1, .item2, .item3, .item4 {

text-align: left;

}

.item1 {

font-size: 1.2rem;

position:sticky;

top: 0.01rem;

left: 0.01rem;

padding-top: 0.5rem;

padding-right: 0.8rem;

padding-left: 0.8rem;

}

.item1 nav ul li {

padding: 0.2rem 0.2rem;

}

.item1 nav ul li:hover, nav ul li:focus, nav ul li:active {

grid-column: span 20;

color: #5A440D;

list-style-type:none;

text-decoration:none;

font-weight: bold;

letter-spacing: 0.1rem;

}
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — When testing I realized the issue. You have to adjust the `grid-template-columns</C> too:
<CODE>
`<i>
</i> @media print {

body {
text-align: center;
margin: 0;
color: #000;
background-color: #fff;
}

div.container&gt;div:not(.item4) {
display: none;
}

.container {
grid-template-columns: auto;
}


}<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — I do not work. I get two nav list on the screen
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — i send my html css file
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — Where should i put this

<div class="item1 noprint">

<nav>

<ul>

<li><a href="#" id="activePage">Home</a></li>

<li><a href="html/tourism.html">Tourism</a></li>

</ul>

</nav>

</div>
Copy linkTweet thisAlerts:
@NogDogFeb 23.2022 — ["Resonsive grid","Responsive grid"]
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — css file

.container {

display: grid;

grid-template-columns: 200px auto;

background-color: #8EDFCF;

}

.item1, .item2, .item3, .item4 {

text-align: left;

}

.item1 {

font-size: 1.2rem;

position:sticky;

top: 0.01rem;

left: 0.01rem;

padding-top: 0.5rem;

padding-right: 0.8rem;

padding-left: 0.8rem;

}

.item1 nav ul li {

padding: 0.2rem 0.2rem;

}

.item1 nav ul li:hover, nav ul li:focus, nav ul li:active {

grid-column: span 20;

color: #5A440D;

list-style-type:none;

text-decoration:none;

font-weight: bold;

letter-spacing: 0.1rem;

}



-----------------------------------------------
index.html

<body>

<div class="container">

<div class="item1">

<nav>

<ul>

<li><a href="#" id="activePage">Home</a></li>

<li><a href="html/tourism.html">Tourism</a></li>

</ul>

</nav>

</div>

<div class="item1 noprint">
<nav>
<ul>
<li><a href="#" id="activePage">Home</a></li>
<li><a href="html/tourism.html">Tourism</a></li>
</ul>
</nav>
</div>

<div class="item2">
<img src="images/cropped-IMG_7105.jpg" />

</div>

<div class="item3">
</div>

<div class="item4">
<article class="info">
<h2>hjkjhk</h2>
</article>

<article class="news">
<h2>Senaste nytt</h2>
<h3>Party</h3>
<p>2019-04-06</p>
<p>kgk.</p>
<img src="images/party.jpg" />
<img src="images/party2.jpg" />
</article>

<article class="fence">
<h3>cfdt</h3>
<p>2018-07-16</p>
<p>ghjhg.</p>
<img src="images/fence.jpg" />
<img src="images/fence2.jpg" />

<br>
<img src="images/lawn.jpg" />
<img src="images/lawn2.jpg" />

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc faucibus a pellentesque sit.
Ultrices gravida dictum fusce ut placerat orci nulla. Tempor orci eu lobortis elementum nibh tellus. Faucibus vitae aliquet nec ullamcorper sit. Vestibulum lorem sed risus ultricies tristique nulla. Pellentesque nec nam aliquam sem et.
Aenean sed adipiscing diam don
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — Forget what I wrote about the class "noprint". Take your page as it is and add my latest CSS. For me it worked fine.
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — it works
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — Are there any easy way to shrink my print out page?
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — You might apply some margin.
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — I want to add this to my print out

<div class="item2">

<img src="images/cropped-IMG_7105.jpg" />

<p>lklkj</p>

</div>
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — i mean only p>lklkj</p>

not the image
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — Change the CSS to this:
``<i>
</i> @media print {

body {
text-align: center;
margin: 0;
color: #000;
background-color: #fff;
}

/*hide item1 and image in item 2 */
div.container&gt;div.item1,
div.container&gt;div.item2 img {
display: none;
}

.container {
grid-template-columns: auto;
}

}<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — If i want to resize the pics in body
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — Any idea
Copy linkTweet thisAlerts:
@SempervivumFeb 23.2022 — Feel free to add more CSS in order to resize the images:
``<i>
</i> @media print {

body {
text-align: center;
margin: 0;
color: #000;
background-color: #fff;
}

/* hide item1 and image in item 2: */
div.container&gt;div.item1,
div.container&gt;div.item2 img {
display: none;
}

/* resize images inside item4: */
div.container&gt;div.item4 img {
width: 300px;
}
.container {
grid-template-columns: auto;
}

}<i>
</i>
``
Copy linkTweet thisAlerts:
@Ashley128authorFeb 23.2022 — it work. thanks.
×

Success!

Help @Ashley128 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...