File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ const container = document . querySelector ( ".content" ) ;
2+ const baseURL = "https://source.unsplash.com/random/" ;
3+ const rows = 7 ;
4+
5+ for ( let i = 0 ; i < rows * 3 ; i ++ ) {
6+ const img = document . createElement ( "img" ) ;
7+ img . src = `${ baseURL } ${ randomSize ( ) } ` ;
8+ container . appendChild ( img ) ;
9+ }
10+
11+ function randomSize ( ) {
12+ return `${ randomNumber ( ) } x${ randomNumber ( ) } ` ;
13+ }
14+
15+ function randomNumber ( ) {
16+ return Math . floor ( Math . random ( ) * 10 ) + 300 ;
17+ }
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Random Image Feed</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < h1 > Random Image Feed</ h1 >
11+ < div class ="content "> </ div >
12+
13+ < script src ="app.js "> </ script >
14+ </ body >
15+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ box-sizing : border-box;
3+ }
4+
5+ body {
6+ display : flex;
7+ flex-direction : column;
8+ justify-content : center;
9+ align-items : center;
10+ min-height : 100vh ;
11+ margin : 0 ;
12+ font-family : sans-serif;
13+ }
14+
15+ .content {
16+ display : flex;
17+ justify-content : center;
18+ align-items : center;
19+ flex-wrap : wrap;
20+ max-width : 1000px ;
21+ }
22+
23+ .content img {
24+ object-fit : cover;
25+ margin : 10px ;
26+ height : 300px ;
27+ width : 300px ;
28+ max-width : 100% ;
29+ }
You can’t perform that action at this time.
0 commit comments