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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <section class="card" id="card">
        <div class="container card__wrap">
            <figure class="card__image">
                <img class="card__image_item" src="./img/iPhone-graphite.png" alt="iPhone12">
            </figure>
            <div class="card-details">
                <h2 class="card-details__title">Смартфон Apple iPhone 12 Pro 128GB Graphite</h2>
                <ul class="card-detail__buttons">
                    <li class="card-details__wrap-btn">
                        <button class="card-detail__change active" type="button">Графитовый</button>
                    </li>
                    <li class="card-details__wrap-btn">
                        <button class="card-detail__change" type="button">Серебристый</button>
                    </li>
                    <li class="card-details__wrap-btn">
                        <button class="card-detail__change" type="button">Тихоокеанский синий</button>
                    </li>
                </ul>
                <div class="card-details__description">
                    <ul class="card-details__description-list description">
                        <li class="card-details__description-item description__screen">Экран 6.1"/2532x1170 Пикс</li>
                        <li class="card-details__description-item description__tech-screen">Технология экрана OLED</li>
                        <li class="card-details__description-item description__processor">Тип процессора A14 Bionic</li>
                        <li class="card-details__description-item description__memory">Встроенная память (ROM) 128 ГБ</li>
                        <li class="card-details__description-item description__camera">Основная камера МПикс 12/12/12/LiDAR</li>
                    </ul>
                    <a class="card-details__link-characteristics" href="#characteristics">Полные характеристики</a>
                    <div class="card-details__footer">
                        <p class="card-details__price">
                            99990₽
                        </p>
                        <button class="button button_buy card-details__button_buy" data-button-buy="Оплата">Купить</button>
                        <button class="button card-details__button_delivery" data-button-buy="Доставка и оплата">Купить с доставкой</button>
                    </div>
                </div>
            </div>
        </div>
    </section>
              
            
!

CSS

              
                
.container{
    width: 100%;
    max-width: 1000px;
    padding: 0 15px;
    margin: auto;
}
.card {
    padding-top: 90px;
}

.card__wrap {
    display: flex;
    align-items: center;
}

.card__image {
    max-width: 444px;
    margin: 0 70px 0 0;
}

.card-details__title {
    font-size: 36px;
    line-height: 43px;
}

.card-details__wrap-btn:not(:last-child) {
    margin-right: 24px;
}

.card-detail__buttons {
    display: flex;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 40px;
    white-space: nowrap;
}

.card-detail__change {
    border: 1px solid transparent;
    background-color: transparent;
    padding: 11px 16px;
}

.card-detail__change.active {
    color: #FE3B3B;
    border-bottom: 1px solid #FE3B3B;
}

.card-details__description {
    font-weight: 300;
    font-size: 18px;
    line-height: 21px;
    margin-bottom: 20px;
}

.card-details__description-list {
    margin-bottom: 18px;
}

.card-details__footer {
    display: flex;
    align-items: center;
}

.card-details__price {
    min-width: 120px;
    font-weight: 700;
    font-size: 24px;
    margin-right: 60px;
}

.card-details__link-characteristics {
    display: block;
    color: #4F80FF;
    font-size: 18px;
    line-height: 21px;
    margin-bottom: 60px;
}

.card-details__button_buy {
    margin-right: 28px;
}

@media (max-width: 968px) {
    .card{
        padding-top: 50px;
    }

    .card__wrap {
        flex-direction: column;
    }

    .card__image {
        order: 1;
        margin-right: 0;
    }

    .card-details {
        max-width: 600px;
        margin-bottom: 30px;
    }
}

@media (max-width: 698px) {
    .card-details {
        max-width: 400px;
        margin-bottom: 20px;
    }

    .card-details__title {
        text-align: center;
        font-size: 28px;
        margin-bottom: 30px;
    }

    .card-detail__buttons {
        flex-direction: column;
        align-items: center;
    }

    .card-details__wrap-btn:not(:last-child) {
        margin-right: 0;
        margin-bottom: 15px;
    }
    .card-details__footer {
        flex-wrap: wrap;
        align-items: start;
    }

    .card-details__price {
        width: 100%;
        margin-right: 0;
        margin-bottom: 30px;
    }

    .card-details__button_buy {
        margin-bottom: 30px;
    }
}

              
            
!

JS

              
                // Функция для работы табов.
const tabs = () => {
	// Кнопки переключения табов.
	const cardDetailChangeElems = document
		.querySelectorAll('.card-detail__change')
	// Заголовок выбранного таба.
	const cardDetailsTitleElem = document
		.querySelector('.card-details__title')
	// Картинка товара выбранного таба.
	const cardImageItemElem = document.querySelector('.card__image_item')
	// Цена товара выбранного таба.
	const cardDetailsPriceElem = document
		.querySelector('.card-details__price')
	// Встроенная память (ROM) товара в выбранном табе.
	const descriptionMemoryElem = document
		.querySelector('.description__memory')

	// Данные всех телефонов, которые есть в наличии.
	const data = [
		{
			name: 'Смартфон Apple iPhone 12 Pro 128GB Graphite',
			img: './img/iPhone-graphite.png',
			price: 95990,
			memoryROM: 128,
		},
		{
			name: 'Смартфон Apple iPhone 12 Pro 256GB Silver',
			img: './img/iPhone-silver.png',
			price: 120000,
			memoryROM: 256,
		},
		{
			name: 'Смартфон Apple iPhone 12 Pro 128GB Pacific Blue',
			img: './img/iPhone-blue.png',
			price: 99990,
			memoryROM: 128,
		},
	]

	// Функция убирает выделение со всех кнопок переключения табов.
	const deactive = () => {
		// Пройти по всем кнопкам переключения табов.
		// Убрать выделение с выбранной кнопки переключения таба.
		cardDetailChangeElems.forEach(btn => btn.classList.remove('active'))
	}

	// Пройти по всем кнопкам переключения табов.
	cardDetailChangeElems.forEach((btn, i) => {
		btn.addEventListener('click', () => {
			// Если кнопка переключения таба НЕ активная:
			if (!btn.classList.contains('active')) {
				deactive()
				// Выделить кнопку переключения таба.
				btn.classList.add('active')

				// Изменить содержимое элементов таба.
				cardDetailsTitleElem.textContent = data[i].name
				cardImageItemElem.src = data[i].img
				cardImageItemElem.alt = data[i].name
				cardDetailsPriceElem.textContent = `${data[i].price}₽`
				descriptionMemoryElem.textContent =
					`Встроенная память (ROM) ${data[i].memoryROM} ГБ`
			}
		})
	})
}
tabs();
              
            
!
999px

Console