CLG Logo

The Source

Coding has always been my passion and I think it is a really great idea to share code snippets that I find useful and apply to website design.


Centering an element in a div

Using Flexbox to position an element in the Center of a div. For This exercise we use a responsive image as the element.

example image

<div class="mybox">
    <img src="images/flexbox.jpg" alt="example image" class="responsive" >
</div>

.mybox {
height: 35vh; // height of div responsive to 35% of viewport
width: 70%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
border: 1px dashed black;
}

.responsive {
      width: 100%;
  max-width: 360px;
  height: auto;
}

Customizing the scroll bar

Creating a custom scroll bar can augment the website identity to match to company apprentice.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.



<div class="mywindow">
    <p>Lorem Ipsum is simply dummy text of the printin...
</p>

.mywindow {
height: 25vh;
width: 70%;
  border: 1px dashed black;
  margin: auto;
  overflow: hidden;
  overflow-y: scroll;

}

/* width */
.mywindow::-webkit-scrollbar {
  width: 20px;
cursor: pointer;

}

/* Track */
.mywindow::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px grey; 
  border-radius: 10px;
}
 
/* Handle */
.mywindow::-webkit-scrollbar-thumb {
  background-color: #569dcc;
  border-radius: 10px;
   box-shadow: inset 0 0 5px black; 
}

/* Handle on hover */
.mywindow::-webkit-scrollbar-thumb:hover {
   background-color: #569dcc;
}

Sticky Footer Using Flex

A sticky footer that uses a variable height is the best in respensive web design.


<body>
  <div class="content">
    content
  </div>
  <footer class="footer"></footer>
</body>

html, body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1 0 auto;
}
.footer {
  flex-shrink: 0;
}


CLOSE (X)

Send us a message...

On-line Email Web Form