Готовый код html корзина

10 CSS & JavaScript Snippets for Creating eCommerce UIs

eCommerce carts need to be usable and accessible for all visitors. Your goal is to increase conversions and keep people engaged during checkout, and the best way to do this is with a clean design that encourages user activity.

There are many free open source shopping carts you can restyle for any purpose. And we’ve taken the liberty of collecting our favorites in this collection.

Flat Cart

There’s no denying the popularity of flat design. It works for all types of websites, and it helps designers focus more on usability rather than aesthetics.

That’s why this flat cart makes an excellent resource for anyone building an eCommerce checkout page. The colors are easy to update and the interface features work the same regardless of layout style.

I don’t think flat design is the solution for every project, but in the right scenario this pen can work well as a starting template.

See the Pen Flat Cart [codepen comp] by Will Paige

Table-Free UI

Many checkout pages use tables to organize data but this example by Alex Rodrigues uses DIV s instead.

It is fully responsive, so the layout should look great no matter what device you’re using. Each row holds enough data to restyle properly and keep everything organized, even on super small screens. And the CSS code uses Compass to save time along with free Google Fonts for a little style.

Delicious Shopping Cart

I can’t imagine this working on a real site but as a UI/UX experiment it is pretty cool. The self-titled Delicious Shopping Cart acts like an online bakery/sweets store with photos of different desserts.

You can move your cursor left/right to advance through the carousel or swipe on a mobile device. Each item has plus/minus icons for adding items or removing them from your order, plus an ‘X’ icon to remove it entirely from your cart.

The whole thing is built on Sass, Slim, and jQuery, so it’s one heck of a frontend project! If you’re looking to dissect some great code, this example is worth saving.

Responsive Design

Here’s another simple responsive shopping cart UI built on Sass and table-free.

I like this responsive checkout a little more than the others because the breakpoints feel more natural. Even on smaller screens, the cart items don’t feel cramped or out of place.

Читайте также:  Python module config file

All of the “remove” buttons work through JavaScript, and the numeric input fields auto-update pricing. This is great for a frontend cart page where the buyer may want to increase quantities before paying and to see an estimate of the total costs.

See the Pen Responsive Shopping Cart by Justin Klemm

jQuery Shopping Basket

This pen acts more like a wireframe than a full checkout page but it’s perfect as a starting point. Developer Khurram Alvi created this responsive shopping cart with basic HTML/CSS and a little jQuery.

It is fully responsive, and the quantity inputs work as you’d expect. One nice thing is the simplicity of this cart’s design. It doesn’t impose any colors, fonts, or textures into the layout. Anyone looking to build a new cart from scratch might start here because it’s easy to build onto and restructure.

Challenge Cart

Every so often new CodePen challenges pop up asking developers to create different interfaces like signup pages or modal windows. This pen by Žiga Miklič came from a challenge for shopping cart UIs and it’s a masterpiece of frontend development.

When you add/remove items from the cart, you’ll notice the prices automatically update with a small sliding animation. You can also click any product image to remove it from the cart with ease. These small features add a lot to the interface and make cloning a breeze.

Even the checkout function has its own animated feature, although it’s not connected to anything on the backend.

Sliding Cart UI

Tabbed widgets let you add content onto a single page and give users the power over that content. In this sliding cart you can switch between the cart itself and a list of saved “favorite” items.

None of the checkout features actually work, so you can’t favorite or add/remove items into the cart. But the interface items are in place, so a little JavaScript magic would fix that. Still, I’m impressed with how clean this cart looks and the unique-yet-usable tab interface.

Dynamic Store & Cart

Mixing the store and shopping cart into one interface is a tough job but Olivia Cheng got it done in this pen.

It uses wide thumbnails in a grid set up with an “add to cart” button on hover. Click this to add the item above with auto-updating prices. One unique feature is the quantity added on top of the item thumbnail. This might get confusing on a real cart, but if the numbers were a bit smaller, this would be a great way to save space.

See the Pen Sliding Shopping Cart & Store by Olivia Cheng

Clean Shopping Cart

Developer Bart Veneman created this clean shopping cart as a simple interface template. It auto-calculates the total price and even includes taxes near the checkout button.

Читайте также:  Html list style values

All of these dynamic features work through JavaScript and surprisingly this pen uses Zepto over jQuery. This is great for devs who prefer the Zepto library, but really anyone could pick up this code and rework it to suit any template.

See the Pen Shopping Cart by Bart Veneman

Simple Cart with Vue.js

Frontend coding with Vue.js makes templating a whole lot simpler. And this pen is one example of a dynamic cart practically built on a JavaScript foundation.

The cart auto-updates with each click so you can add/remove items and see results instantly. The top-right button opens your current cart in a modal window using Bootstrap’s modal component.

If you like the Vue.js syntax, then this template is a great place to start building a shopping cart. It’s easy to customize and should work well in all browsers.

See the Pen VueJS 2 Simple Shopping cart by Cristian Matos

Domain Cart

Here’s one of my favorite shopping cart designs modeled after a domain registrar. Coder Jesse Bilsten got detailed with this interface including a payment section and a required T&C area.

You have to click the “I agree” button before completing the checkout process. It’s a minor yet valuable feature for some eCommerce sites, and I really like the two-column layout. And this design is totally responsive so you can clone it for use in pretty much any eCommerce system.

This page may contain affiliate links. At no extra cost to you, we may earn a commission from any purchase via the links on our site. You can read our Disclosure Policy at any time.

Источник

Корзина для сайта магазина с помощью CSS и JavaScript

В этом руководстве мы продемонстрируем как создать корзину для интернет-магазина с использованием HTML и CSS3 . При этом мы применим Google Fonts ( шрифт « Roboto » ).

HTML

Шаг 1: Создадим HTML-структуру

Сначала нужно создать контейнер div , который мы назовем « .shopping-cart ».

Внутри него у нас будет заголовок и три пункта, которые будут содержать:

  • Кнопку « Удалить » и кнопку « Добавить в избранное »;
  • Изображение товара;
  • Название и описание товара;
  • Кнопки, с помощью которых можно задавать количество товара;
  • Итоговую цену.
 
Shopping Bag
Готовый код html корзина
Common Projects Bball High White
$549
Готовый код html корзина
Maison Margiela Future Sneakers White
$870
Готовый код html корзина
Our Legacy Brushed Scarf Brown
$349

CSS

Убедитесь, что при создании корзины для сайта на PHP вы подключили шрифт, который мы используем в этом руководстве. Теперь добавим основные стили для раздела body :

После этого создадим корзину с размерами 750 на 423 пикселя и зададим для нее стили. Обратите внимание, что мы используем flexbox , поэтому устанавливаем для свойства display значение flex , а для flex-direction – column . Потому что по умолчанию для flex-direction установлено значение row :

Читайте также:  Эхо сервер на python

Теперь создадим первый элемент корзины для сайта на JavaScript , который будет названием товара. Для этого изменим значение высоты на 60 пикселей и зададим несколько основных стилей. Следующие три элемента — это товары в корзине. Для каждого из них мы установим высоту 120 пикселей и display: flex :

Мы задали основные стили. Теперь по порядку установим стили для товаров. Первыми элементами являются кнопки « Удалить » и « Добавить в избранное ».

Мне всегда нравилась анимация кнопок-сердечек Twitter . Я думаю, что она будет отлично смотреться в скрипте корзины для сайта:

.buttons < position: relative; padding-top: 30px; margin-right: 60px; >.delete-btn, .like-btn < display: inline-block; Cursor: pointer; >.delete-btn < width: 18px; height: 17px; background: url("delete-icn.svg") no-repeat center; >.like-btn

Мы устанавливаем класс « is-active » при нажатии кнопки, чтобы анимировать ее с помощью jQuery , но об этом подробнее в следующем разделе:

.is-active < animation-name: animate; animation-duration: .8s; animation-iteration-count: 1; animation-timing-function: steps(28); animation-fill-mode: forwards; >@keyframes animate < 0% < background-position: left; >50% < background-position: right; >100% < background-position: right; >>

Следующий элемент скрипта корзины для сайта HTML — это изображение товара, для которого нужно задать поле справа 50 пикселей:

.image < margin-right: 50px; >Let’s add some basic style to product name and description. .description < padding-top: 10px; margin-right: 60px; width: 115px; >.description span < display: block; font-size: 14px; color: #43484D; font-weight: 400; >.description span:first-child < margin-bottom: 5px; >.description span:last-child

Далее нужно задать стили для количества приобретаемого товара: кнопки для увеличения и уменьшения количества. Сначала мы создадим CSS корзины покупок для сайта, а затем заставим его работать с помощью JavaScript :

.quantity < padding-top: 20px; margin-right: 60px; >.quantity input < -webkit-appearance: none; border: none; text-align: center; width: 32px; font-size: 16px; color: #43484D; font-weight: 300; >button[class*=btn] < width: 30px; height: 30px; background-color: #E1E8EE; border-radius: 6px; border: none; cursor: pointer; >.minus-btn img < margin-bottom: 3px; >.plus-btn img < margin-top: 2px; >button:focus, input:focus

Также реализуем функцию адаптивности корзины для HTML сайта , добавив следующие строки кода:

@media (max-width: 800px) < .shopping-cart < width: 100%; height: auto; overflow: hidden; >.item < height: auto; flex-wrap: wrap; justify-content: center; >.image img < width: 50%; >.image, .quantity, .description < width: 100%; text-align: center; margin: 6px 0; >.buttons < margin-right: 20px; >>

JavaScript

Перед тем, как сделать корзину на сайте , создадим анимацию сердечек, которая будет запускаться, когда пользователь нажимает на них:

Теперь заставим работать кнопки количества приобретаемого товара:

$('.minus-btn').on('click', function(e) < e.preventDefault(); var $this = $(this); var $input = $this.closest('div').find('input'); var value = parseInt($input.val()); if (value > 1) < value = value - 1; >else < value = 0; >$input.val(value); >); $('.plus-btn').on('click', function(e) < e.preventDefault(); var $this = $(this); var $input = $this.closest('div').find('input'); var value = parseInt($input.val()); if (value < 100) < value = value + 1; >else < value =100; >$input.val(value); >);

И это наша окончательная версия корзины товаров для сайта :

Руководство завершено! Надеюсь, оно вам понравилось, и вы узнали что-то новое. Если у вас есть вопросы, напишите об этом в комментариях!

Источник

Оцените статью