Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
<!-- Proof of concept: compatible with Internet Explorer 8 --> <!DOCTYPE html> <html lang="en"> <head> <title>Grid and list layout toggle demo</title> <meta name="author" content="Elominius from Wikiversity"> <!-- necessary to render the interpuncts correctly in older browser versions --> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <!-- compatibility --> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div class="toggle_grid_list_buttons"> <!-- "Toggle to grid view" button initially hidden --> <button onclick="toggleView_demo();" style="display:none;">Toggle to grid view</button> <button onclick="toggleView_demo();">Toggle to list view</button> </div> <ul class="item_container grid"> <li> <div class="thumbnail_wrapper"> <div class="thumbnail_container"> <!-- a picture would go here --> <span class="thumbnail_duration">6:38</span> </div> </div> <div class="info_wrapper"> <div class="title_container" title="This is a title."> <!-- fake hyperlink colour for illustration purposes --> <span class=fake_URL>This is a title.</span> </div> <div class="status_container"> <!-- non-breaking spaces after numbers --> by <span class="channel_name fake_URL" title="312,147 subscribers">VideoCreator</span> <span class="subscriber_count list_show">(312,147 subscribers)</span> • <time class="upload_date" datetime="2022-06-12T10:11:16" title="June 12, 2022 10:11:16 (UTC)">2 weeks ago</time> • <span class="view_count" title="56,887 views since 24 hours">1,013,237 views</span> • <span class="rating" title="106,228 likes, 3187 dislikes">97% liked</span> </div> <div class="description_container list_show"> This is the description. It can only be seen in list view. It does not matter if it contains too much text for the space, since excess text can be hidden or extend downwards. </div> </div> </li> </ul> <!-- This "type" attribute serves as a label for the source code, and is not necessary in modern browsers. Same with "text/javascript". --> <style type="text/css"> /* font pack */ body { font-family: 'noto sans', ubuntu, 'segoe ui', futura, arial, helvetica, 'trebuchet ms', tahoma, verdana, sans-serif; } /* shared style */ .item_container { list-style: none; padding-right: 1em; } .thumbnail_container { width:256px; height:144px; position: relative; /* necessary to keep .thumbnail_duration inside thumbnail */ border: 2px solid grey; margin-right: 1em; margin-bottom: 0.5em; background-color: lightblue; /* placeholder */ border-radius: 5px; } .title_container { font-size:20pt; } .fake_URL { color:#48C; } /* for illustration */ .status_container { font-size:10pt; color:#555; padding-bottom:5pt; } .description_container { display:block; /* description height limit */ max-height:5em; /* 5 lines */ overflow-y: hidden; /* hide excess text */ /* end line with ellipsis for newer browsers */ /* display: -webkit-box; text-overflow:ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp: 5; */ } .thumbnail_duration { display: inline-block; position: absolute; background-color: rgba(0,0,0,0.5); padding:0 4px; bottom:0; right:0; border-radius: 5px; /* fallback */ border-radius: 5px 0 3px 0; } /* only visible in specific modes */ .grid_show { display: none; } .list_show { display: none; } /* grid view */ .item_container.grid .grid_show { display: inline; } /* moves title closer to video above than below to clarify that it belongs to the former */ .item_container.grid .status_container { padding-bottom: 15pt; } .item_container.grid .thumbnail_container { margin-bottom: 0; } .item_container.grid li { /* limit width per item */ display: inline-block; width: 256px; margin-right:1em; } /* hide description – obsolete due to .list_show */ /* .item_container.grid .description_container { display:none; } */ /* list view */ .item_container.list .list_show { display: inline; } .item_container.list .description_container { display:block; width:calc(100% - 300px); /* limit width to avoid breaking underneath */ } .item_container.list li { display:block; clear:both; } /* extend over entire row */ .item_container.list .thumbnail_wrapper { display: inline-block; width: 256px; float:left; margin-right: 1em; } .item_container.list .info_wrapper { /* Deactivated due to possibility of it getting below the thumbnail. Might be necessary on older browsers, but would require fixed width. */ /* display: inline-block; */ /* width: 256px; */ } /* responsive width - puts information below thumbnail on narrow displays (optional) */ @media (max-width: 720px) { .item_container.list .thumbnail_wrapper { float:none; } .item_container.list .description_container { width: 100%; } } /* dark theme (optional) */ body { background-color:#222; color:#eee; } .status_container { color:#aaa; } </style> <script type="text/javascript"> // put item container into shortcut variable var item_container = document.querySelectorAll(".item_container")[0]; var first_item = item_container.querySelectorAll("li")[0]; var toggle_grid_list_buttons = document.querySelectorAll(".toggle_grid_list_buttons")[0].querySelectorAll("button"); // set view function setView(mode) { // if none set, default to grid if (item_container.getAttribute("class").search("grid")+item_container.getAttribute("class").search("list") == -2) { item_container.getAttribute("class")="item_container grid"; document.cookie = "view_mode=grid"; } switch(mode) { case "list": // replaces the "grid" class with "list" item_container.setAttribute("class",item_container.getAttribute("class").replace('grid','list') ); // hides "toggle to list view" button and shows "toggle to grid view" button toggle_grid_list_buttons[0].style.display="block"; toggle_grid_list_buttons[1].style.display="none"; // stores view mode into cookie document.cookie = "view_mode=list"; break; case "grid": // replaces the "list" class with "grid" item_container.setAttribute("class",item_container.getAttribute("class").replace('list','grid') ); // hides "toggle to grid view" button and shows "toggle to list view" button toggle_grid_list_buttons[0].style.display="none"; toggle_grid_list_buttons[1].style.display="block"; // stores view mode into cookie document.cookie = "view_mode=grid"; break; } } // toggle view function toggleView_demo(mode) { if ( // checks if grid mode is activated by looking for the word "grid" in the class item_container.getAttribute("class").search("grid") > -1 ) { setView("list"); } else if ( // checks for list mode item_container.getAttribute("class").search("list") > -1 ) { setView("grid"); } else { // add "grid" class by default item_container.getAttribute("class")+=" grid"; document.cookie = "view_mode=grid"; } } // Cookie function dependencies function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires="+d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } // check configuration (note: only Firefox stores cookies for locally opened HTML files.) if ( getCookie("view_mode") == "grid" ) setView("grid"); if ( getCookie("view_mode") == "list" ) setView("list"); // Description width fallback for older browsers – uncomment and optionally convert to "onresize" if necessary. /* document.body.appendChild( document.createElement("style") ); var description_width_fallback = document.body.lastChild; document.body.lastChild.getAttribute("class")="description_width_fallback"; // label for page inspector window.addEventListener('resize', function(event) { if ( item_container.getAttribute("class").search("list") > -1 ) { description_width_fallback.innerHTML = ".item_container.list .description_container { width: " + (first_item.offsetWidth-400) +"px; }"; } }, true); */ // Multiply list items for illustrative purposes – the following code would not be implemented on an actual web site. var li_1_content = first_item.innerHTML; var color_list = ['darkred', 'green', 'blue', 'yellow', 'orange', 'darkorange', 'darkgreen', 'darkseagreen', 'lightyellow', 'lightblue', 'lightskyblue', 'lightgreen', 'teal', 'turquoise', 'darkturquoise', 'mediumturquoise', 'lightcoral', 'antiquewhite', 'aqua', 'aquamarine', 'purple', 'violet', 'darkviolet', 'indigo', '#38F', 'lightseagreen', 'deepskyblue', 'steelblue', 'royalblue', 'beige', 'ivory', 'gray', 'slategray', 'darkslategray', 'wheat', 'gold', 'silver', 'brown', 'olive', 'lime', 'limegreen', 'greenyellow', 'yellowgreen', 'seagreen', 'crimson']; var count = 0; for ( count = 0; // start counter count < Math.floor(10+Math.random()*40); // repeat 10 to 50 times count++ // count up ) { item_container.appendChild( document.createElement("li") ); item_container.lastChild.innerHTML=li_1_content; // random color var random_number = Math.floor(Math.random()*(color_list.length)); item_container.lastChild.querySelectorAll(".thumbnail_container")[0].style.backgroundColor=color_list[random_number]; } </script> </body> </html>
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
⭐ $12,000 two day
CSS | 6 min ago | 0.99 KB
Untitled
16 min ago | 0.06 KB
API-Flaw Profit Guide
CSS | 48 min ago | 0.99 KB
Schrödinger's Crit
3 days ago | 15.37 KB
PRCE internal cursor
3 days ago | 0.73 KB
AI Interaction Method
3 days ago | 1.60 KB
awkwrapper.c
C | 3 days ago | 2.35 KB
z66is_archive.zip.txt
3 days ago | 39.19 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!