Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="root"></div>
<div class="article">
  <div class ="rectangle"></div>
  <h1>An ocean from Ancient</h1>
  <p>Saline water covers approximately 361,000,000 km2 (139,000,000 sq mi) and is customarily divided into several principal oceans and smaller seas, with the ocean covering approximately 71% of Earth's surface and 90% of the Earth's biosphere.[6] The ocean contains 97% of Earth's water, and oceanographers have stated that less than 5% of the World Ocean has been explored.[6] The total volume is approximately 1.35 billion cubic kilometers (320 million cu mi) with an average depth of nearly 3,700 meters (12,100 ft)</p>
    <button>world ocean </button>
    <a target="_blank" title="instagram/web__addict" href="https://www.instagram.com/web__addict/"><i class="fab fa-instagram"></i></a>
</div>

              
            
!

CSS

              
                 /*<< important styles*/
.slider{
  position: relative;
  width: auto;
}

.slider-container {
  max-width: 760px;
  max-height: 804px;
  width: 100%;
  height: auto;
  overflow: hidden;
  position: relative;
}
.controler{
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  right: -6%;
  top: 37%;
  max-width: 600px;
  max-height: 600px;
  width: 100%;
  height: 25vw;
  background: #A7C3DB;
  position: absolute;
  font-size: 90px;
}

.slider-innerContainer {
  transition: left 0.8s ease-out;
  display: flex;
  position: relative;
  height: 100%;
  flex-shrink: 0;
}
.slider-innerContainer > * {
  width: 100%;
  height: auto;
}
img {
  object-fit: cover;
  height: 100%;
  width: 100%;
}

.slider-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
}

.slider-dots div {
  cursor: pointer;
  width: 40px;
  height: 40px;
}

.slid__number{
  position: relative;
  z-index: 2;
  bottom: 25%;
  font-size: 72px;
  font-weight: 800;
}

.slid__arrow{
  height: 40px;
  margin-bottom: 60px;
  cursor: pointer;
}
 /*important styles >>*/
body{
  display: flex;
  justify-content: center;
  align-items: center;
  color: #011D6A;
} 

.article{
  position: relativ;
  margin-left: 180px;
  margin-right: 100px;
  max-width: 810px;
}

h1{
  font-family: 'Chonburi', cursive;
  font-size: 62px;
  margin-left: -40px;
}
p{
  font-family: 'Heebo', sans-serif;
  font-size: 18px;
  line-height: 26px;
}

button {
  margin-top: 20px;
  background-color: #011D6A; 
  border: none;
  color: white;
  padding: 15px 30px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 5px;
}

.rectangle{
  position: absolute;
  z-index: -1;
  top: 10%;
  right: 0;
  background: #3280a769;
  width: 25%;
  height: 45%;
}
@media screen and (max-width: 900px) {
  body{
    display: flex;
    flex-direction: column;
  } 
  .controler{
    background: transparent;
    z-index: 2;
    right: 0; 
    bottom: 0; 
    width: 300px;
  }
  .slid__arrow{
    position: relative;
    z-index: 1;
    margin-bottom: -40px;
  }
  .slid__number {
    z-index: 2;
    bottom: -40%;
  }
  .slider-dots{
    margin-left: 20px;
  }
 }
.fa-instagram{
  position: absolute;
  bottom: 83%;
  right: 2%;
  font-size: 38px;
  color: #011D6A;
}

.fa-instagram:hover{
  font-size: 42px;
  color: #dca118;
  transition: all .1s linear;
  cursor: pointer;
}
              
            
!

JS

              
                const sliders = [
  {name:"Ocean", src:"https://images.unsplash.com/photo-1511804472014-fa7b871cd6a9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80"},
  {name:"Ocean", src:"https://www.wavecity.in/wp-content/uploads/2017/07/Featured-7-825x510.jpg"},
  {name:"Ocean", src:"https://www.aqua.org/-/media/Images/Events/world-oceans-day/worlds-ocean-desktop-header_5-22-18_1260x558.ashx"},
  {name:"Ocean", src:"https://assets.atlasobscura.com/article_images/40609/image.jpg"}];

class Slider extends React.Component{
  state = {
      sliders,
      active: 0,
      max: sliders.length-1,
    };

  componentDidMount() {
    this.interval = setInterval( () => this.intervalBetweenSlides(), 5000); 
  }
  componentWillUnmount() {
    clearInterval( this.interval);
  }
  intervalBetweenSlides(){ 
    if (this.state.active === this.state.max) {
        this.setState({
          active: 0,
        });
    } else {
      this.setState({
          active: this.state.active+1,
        });
    }
  }
  
  isActive = value => {
    if(this.state.active === value-1){
        return 'active';
    }
  }

  nextOne = () =>{
    if (this.state.active < this.state.max) {
      this.setState({
        active: this.state.active + 1
      });
    }
    else {
      this.setState({
          active: 0,
      });
    }
  }
  prevOne = () => {
    if (this.state.active > 0) {  
      this.setState({
        active: this.state.active - 1
      });
    }
    else {
      this.setState({
        active: this.state.max
      });
    }
  }
  
  dotClicked = e => {
    this.setState({
      active: parseInt(e.currentTarget.dataset.index, 10)-1
    });
  };

  setSliderStyles(){
    return {
      left: -100 * this.state.active + "%"
    }
  };

  render() {
    const {sliders} = this.state;
    return (
    <div className="slider">
        <div className="controler">
          <div onClick={ this.prevOne} className="slid__arrow back"  alt="prev slid">
                &#x2039;
          </div>
          <span className="slid__number">0{this.state.active+1}</span>
          <div  onClick={this.nextOne} className="slid__arrow next"  alt="next slid">
                &#8250;
          </div>
       </div>
      
      <div className="slider-container">
        <div
          className="slider-innerContainer"
          style={this.setSliderStyles() }>
            {sliders.map((slider, index) =>
                <img key={index++} src={slider.src} alt={slider.name}/>
            )}
        </div>
        <div className="slider-dots">
          {sliders.map((slider, index) =>
            <div key={index++} data-index={index++} onClick={this.dotClicked} className={this.isActive(index) + ' dots' }>
              {index-2 == this.state.active ? <i className="fas fa-circle"></i> : <i className="far fa-circle"></i>}
            </div>
          )}
        </div>
      </div>
      </div>
    );
  }
}

ReactDOM.render(<Slider/>, document.getElementById('root'));

              
            
!
999px

Console