<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customized Page Layout</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Eraser&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Eraser', sans-serif;
}
/* Adjust button style */
.rounded-none {
border-radius: 0;
}
/* Adjust skew for all divs */
.skew-div {
transform: skewX(-40deg);
}
/* Counteract skew for text */
.skew-text {
transform: skewX(40deg);
}
/* Adjust skew for text in input fields */
input.skew-text {
transform: skewX(0deg);
}
/* Skew the button */
.skew-button {
transform: skewX(-40deg); /* Adjust the skew angle as needed */
}
/* Counter-skew the text inside the button */
.skew-button .unskew-text {
display: block; /* Make span behave like a block element to center the text correctly */
transform: skewX(40deg); /* Apply the opposite skew transformation */
}
</style>
</head>
<body class="bg-gray-800 text-white">
<div class="max-w-2xl mx-auto py-10">
<div class="text-center text-2xl font-bold mb-6">Page Layout Options</div>
<div class="grid gap-2"> <!-- Reduce spacing between divs -->
<!-- Section 1 -->
<div class="grid grid-cols-2 gap-2"> <!-- Reduce spacing between divs -->
<!-- Columns -->
<div class="flex justify-between items-center bg-blue-500 px-4 skew-div rounded-none" style="height: 30px;"> <!-- Add skew-div class -->
<div class="flex-1 flex items-center"> <!-- Adjusted to take up half width -->
<span class="skew-text text-black">Columns</span>
</div>
<input type="number" value="10" class="w-16 bg-blue-300 text-black rounded border border-gray-600 focus:border-blue-500 focus:ring focus:ring-blue-300 focus:ring-opacity-50 skew-text text-center" style="width:50%;" />
</div>
<!-- Rows -->
<div class="flex justify-between items-center bg-blue-500 px-4 skew-div rounded-none" style="height: 30px;"> <!-- Add skew-div class -->
<div class="flex-1 flex items-center"> <!-- Adjusted to take up half width -->
<span class="skew-text text-black">Rows</span>
</div>
<input type="number" value="10" class="w-16 bg-blue-300 text-black rounded border border-gray-600 focus:border-blue-500 focus:ring focus:ring-blue-300 focus:ring-opacity-50 skew-text text-center" style="width:50%;" />
</div>
</div>
<!-- Section 2 -->
<div class="grid grid-cols-2 gap-2"> <!-- Reduce spacing between divs -->
<!-- Tile Height -->
<div class="flex justify-between items-center bg-blue-500 px-4 skew-div rounded-none" style="height: 30px;"> <!-- Add skew-div class -->
<div class="flex-1 flex items-center"> <!-- Adjusted to take up half width -->
<span class="skew-text text-black">Tile Height</span>
</div>
<input type="number" value="10" class="w-16 bg-blue-300 text-black rounded border border-gray-600 focus:border-blue-500 focus:ring focus:ring-blue-300 focus:ring-opacity-50 skew-text text-center" style="width:50%;" />
</div>
<!-- Tile Width -->
<div class="flex justify-between items-center bg-blue-500 px-4 skew-div rounded-none" style="height: 30px;"> <!-- Add skew-div class -->
<div class="flex-1 flex items-center"> <!-- Adjusted to take up half width -->
<span class="skew-text text-black">Tile Width</span>
</div>
<input type="number" value="10" class="w-16 bg-blue-300 text-black rounded border border-gray-600 focus:border-blue-500 focus:ring focus:ring-blue-300 focus:ring-opacity-50 skew-text text-center" style="width:50%;" />
</div>
</div>
<!-- Password -->
<div class="grid grid-cols-2 gap-2">
<div class="flex justify-between items-center bg-blue-500 px-4 skew-div rounded-none" style="height: 30px;"> <!-- Add skew-div class -->
<div class="flex-1 flex items-center"> <!-- Adjusted to take up half width -->
<span class="skew-text text-black">Password</span>
</div>
<input type="number" value="10" class="w-16 bg-blue-300 text-black rounded border border-gray-600 focus:border-blue-500 focus:ring focus:ring-blue-300 focus:ring-opacity-50 skew-text text-center" style="width:50%;" />
</div>
</div>
<!-- Other Sections Omitted for Brevity -->
</div>
</div>
</body>
</html>
In working on a customized webpage layout that incorporates a unique visual design using CSS skewed div elements, I encountered an issue with text alignment within <input>
elements contained within these skewed divs. Although I attempted to adjust the skew effect specifically for the text inside the inputs by applying transform: skewX(0deg);
, the text still appeared skewed.
Question:
What alternative CSS technique or property could be utilized to eliminate the skew effect from the text inside the input fields while maintaining the desired skew effect on the surrounding div elements? Is there a more effective solution to achieve this specific styling requirement?