Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit c98db00

Browse files
committed
Make the page responsive down to 780px.
The page scales fluidly, and we remove the tagline in the discussions section when necessary to make the header fit.
1 parent 791c76a commit c98db00

File tree

6 files changed

+69
-15
lines changed

6 files changed

+69
-15
lines changed

r2/r2/public/static/discussion.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@
6363
#header.discussion {
6464
background: url(/static/background-discussion.jpg) no-repeat top left;
6565
}
66-
67-
#header.discussion #header-img {
68-
height: 55px;
66+
@media (max-width: 975px) {
67+
img#tagline {
68+
display: none !important;
69+
}
6970
}
70-
71-
#header.discussion #tagline {
72-
display: none;
73-
}

r2/r2/public/static/lesswrong.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#content.clear.fullwidth {
22
padding: 0 15px;
3-
width: 920px;
3+
max-width: 920px;
44
}
55

66
div.comment-meta span span {
-3.18 KB
Loading

r2/r2/public/static/main.css

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ body {
3030
background-color: #d8d8d8;
3131
margin: 0;
3232
padding: 0;
33+
word-wrap: break-word;
34+
overflow-wrap: break-word;
3335
}
3436
#wrapper {
3537
background-color: #fff;
@@ -38,19 +40,29 @@ body {
3840
box-shadow: 0px 0px 10px #555;
3941
margin: 0 auto;
4042
padding: 0;
41-
width: 990px;
43+
max-width: 990px;
44+
min-width: 780px;
4245
}
4346
#main {
44-
padding: 15px 20px;
47+
display: table;
48+
table-layout: fixed;
49+
width: 100%;
50+
4551
}
4652
#content {
47-
float: left;
48-
padding: 0 0 0 15px;
49-
width: 695px;
53+
width: 100%;
54+
padding: 15px 20px 20px 35px;
5055
}
5156
#sidebar {
52-
float: right;
5357
width: 220px;
58+
padding: 15px 20px 20px 0;
59+
}
60+
#header {
61+
overflow: hidden;
62+
}
63+
#content, #sidebar {
64+
display: table-cell;
65+
vertical-align: top;
5466
}
5567

5668

@@ -200,7 +212,9 @@ input, select, textarea, button {
200212
a#logo {
201213
display: block;
202214
float: left;
203-
margin: 35px 10px 0 35px;
215+
height: 54px;
216+
overflow: hidden;
217+
margin: 35px 10px 14px 35px;
204218
}
205219
img#tagline {
206220
display: block;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* This JavaScript adds a "min-width" attribute to the viewport meta tag. If
3+
* the device's width is less than the min-width, we will scale the viewport
4+
* to the min-width; otherwise we will leave the meta tag alone.
5+
*
6+
* This script must be added *after* the viewport meta tag, since it relies on
7+
* that tag already being available in the DOM.
8+
*
9+
* Implementation note: The reason we remove the old tag and insert a new one
10+
* is that Firefox doesn't pick up changes to the viewport
11+
* meta tag.
12+
*
13+
* Author: Brendan Long <[email protected]>
14+
* License: Public Domain - http://unlicense.org/
15+
* See: https://github.com/brendanlong/viewport-min-width-polyfill
16+
*/
17+
(function() {
18+
var viewport = document.querySelector("meta[name=viewport]");
19+
console.log("viewport: " + viewport);
20+
if (viewport) {
21+
var content = viewport.getAttribute("content");
22+
var parts = content.split(",");
23+
for (var i = 0; i < parts.length; ++i) {
24+
var part = parts[i].trim();
25+
var pair = part.split("=");
26+
if (pair[0] === "min-width") {
27+
var minWidth = parseInt(pair[1]);
28+
if (screen.width < minWidth) {
29+
document.head.removeChild(viewport);
30+
31+
var newViewport = document.createElement("meta");
32+
newViewport.setAttribute("name", "viewport");
33+
newViewport.setAttribute("content", "width=" + minWidth);
34+
document.head.appendChild(newViewport);
35+
break;
36+
}
37+
}
38+
}
39+
}
40+
})();
41+

r2/r2/templates/base.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
<meta name="description" content="${description | h}" />
3838
%endif
3939
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
40+
<meta name="viewport" content="width=device-width, min-width=780, inital-scale=1.0"/>
41+
<script type="text/javascript" src="${static('viewport-min-width.js')}"></script>
4042
${self.robots()}
4143
##these are globals, so they should be run first
4244
##things that need are referenced by the reddit, the buttons, and

0 commit comments

Comments
 (0)