Both sites use advanced techniques in HTML, CSS and JavaScript. The second is done in HTML5 and it is impressive. So to build similar sites you'd need to have excellent skills in HTML, CSS, and JavaScript, and have a talent for website design in general.
All of which means you need to know a great deal about creating websites. Study and experience will be required. There are lots of tutorials online to help you get started. Good luck!