{"id":23,"date":"2025-04-17T10:02:54","date_gmt":"2025-04-17T08:02:54","guid":{"rendered":"https:\/\/veiraxweb.com\/herramientas\/?page_id=23"},"modified":"2025-04-17T10:23:49","modified_gmt":"2025-04-17T08:23:49","slug":"conversor-de-peso","status":"publish","type":"page","link":"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/","title":{"rendered":"Conversor de Peso"},"content":{"rendered":"\n<style>\n        :root {\n            --bg-color: #f9f9f9;\n            --text-color: #333;\n            --card-bg: white;\n            --border-color: #ddd;\n            --primary-color: #4CAF50;\n            --hover-color: #45a049;\n            --error-color: #ff6b6b;\n            --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n        }\n        .dark-mode {\n            --bg-color: #1a1a1a;\n            --text-color: #f0f0f0;\n            --card-bg: #2d2d2d;\n            --border-color: #444;\n            --primary-color: #66BB6A;\n            --hover-color: #5da962;\n            --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);\n        }\n        body {\n            font-family: Arial, sans-serif;\n            background-color: var(--bg-color);\n            color: var(--text-color);\n            margin: 0 auto;\n            padding: 20px;\n            text-align: center;\n            transition: background 0.3s, color 0.3s;\n        }\n        h1 {\n            color: var(--primary-color);\n            margin-bottom: 20px;\n        }\n        .converter {\n\n            max-width: 500px;\n            background: var(--card-bg);\n            padding: 20px;\n            border-radius: 10px;\n            box-shadow: var(--shadow);\n            margin-bottom: 20px;\n            transition: background 0.3s;\n        }\n        .input-group {\n            display: flex;\n            align-items: center;\n            margin: 10px 0;\n        }\n        input, select, button {\n            padding: 10px;\n            margin: 5px;\n            border: 1px solid var(--border-color);\n            border-radius: 5px;\n            background: var(--card-bg);\n            color: var(--text-color);\n            transition: border 0.3s;\n        }\n        input {\n            flex: 2;\n        }\n        select {\n            flex: 1;\n        }\n        #swapBtn {\n            background: transparent;\n            border: none;\n            font-size: 20px;\n            cursor: pointer;\n            margin: 0 10px;\n            color: var(--primary-color);\n        }\n        #resultValue {\n            cursor: pointer;\n            background: var(--card-bg);\n            font-weight: bold;\n        }\n        #resultValue:hover {\n            border-color: var(--primary-color);\n        }\n        #resultValue.copied {\n            background: var(--primary-color);\n            color: white;\n            border-color: var(--primary-color);\n        }\n        #modeToggle {\n            position: absolute;\n            top: 20px;\n            right: 20px;\n            background: transparent;\n            border: none;\n            cursor: pointer;\n            font-size: 24px;\n            color: var(--text-color);\n        }\n        #history {\n            text-align: left;\n            margin-top: 20px;\n        }\n        #history h3 {\n            border-bottom: 1px solid var(--border-color);\n            padding-bottom: 5px;\n        }\n        #historyList {\n            list-style: none;\n            padding: 0;\n        }\n        #historyList li {\n            padding: 8px 0;\n            border-bottom: 1px dashed var(--border-color);\n            display: flex;\n            justify-content: space-between;\n        }\n        .clear-btn {\n            background: var(--error-color);\n            color: white;\n            border: none;\n            padding: 8px 15px;\n            border-radius: 5px;\n            cursor: pointer;\n            margin-top: 10px;\n            transition: background 0.3s;\n        }\n        .clear-btn:hover {\n            background: #e05555;\n        }\n        .copy-icon {\n            margin-left: 10px;\n            opacity: 0.7;\n        }\n        .copy-icon:hover {\n            opacity: 1;\n        }\n\nmain .has-global-padding {\nmargin-top: 0!important;\npadding-top: 0!important;\n}\n    <\/style>\n\n\n\n<button id=\"modeToggle\">\ud83c\udf19<\/button>\n    <div class=\"converter\">\n        <div class=\"input-group\">\n            <input type=\"number\" id=\"amount\" placeholder=\"Ej: 100\" step=\"0.01\" oninput=\"convertAuto()\">\n            <select id=\"fromUnit\" onchange=\"convertAuto()\">\n                <option value=\"g\">Gramos (g)<\/option>\n                <option value=\"kg\">Kilogramos (kg)<\/option>\n                <option value=\"lb\">Libras (lb)<\/option>\n                <option value=\"oz\">Onzas (oz)<\/option>\n            <\/select>\n        <\/div>\n        <div class=\"input-group\" style=\"justify-content: center;\">\n            <button id=\"swapBtn\" onclick=\"swapUnits()\" title=\"Intercambiar unidades\">\u2194\ufe0f<\/button>\n        <\/div>\n        <div class=\"input-group\">\n            <input type=\"text\" id=\"resultValue\" readonly onclick=\"copyResult()\" title=\"Clic para copiar\">\n            <select id=\"toUnit\" onchange=\"convertAuto()\">\n                <option value=\"kg\">Kilogramos (kg)<\/option>\n                <option value=\"g\">Gramos (g)<\/option>\n                <option value=\"lb\">Libras (lb)<\/option>\n                <option value=\"oz\">Onzas (oz)<\/option>\n            <\/select>\n        <\/div>\n        <div id=\"result\"><\/div>\n    <\/div>\n\n    <div id=\"history\">\n        <h3>Historial <span class=\"copy-icon\" onclick=\"copyHistory()\" title=\"Copiar historial\">\ud83d\udccb<\/span><\/h3>\n        <ul id=\"historyList\"><\/ul>\n        <button class=\"clear-btn\" onclick=\"clearHistory()\">Limpiar Historial<\/button>\n    <\/div>\n\n\n\n<script>\n        \/\/ Cargar historial y modo al iniciar\n        document.addEventListener('DOMContentLoaded', () => {\n            loadHistory();\n            loadMode();\n            convertAuto();\n        });\n\n        \/\/ Modo oscuro\/claro\n        function loadMode() {\n            const savedMode = localStorage.getItem('darkMode') === 'true';\n            document.body.classList.toggle('dark-mode', savedMode);\n            document.getElementById('modeToggle').textContent = savedMode ? '\u2600\ufe0f' : '\ud83c\udf19';\n        }\n\n        document.getElementById('modeToggle').addEventListener('click', () => {\n            const isDark = document.body.classList.toggle('dark-mode');\n            localStorage.setItem('darkMode', isDark);\n            document.getElementById('modeToggle').textContent = isDark ? '\u2600\ufe0f' : '\ud83c\udf19';\n        });\n\n        \/\/ Conversi\u00f3n autom\u00e1tica\n        function convertAuto() {\n            const amount = parseFloat(document.getElementById(\"amount\").value);\n            if (!isNaN(amount)) convert();\n        }\n\n        \/\/ Funci\u00f3n principal de conversi\u00f3n\n        function convert() {\n            const amount = parseFloat(document.getElementById(\"amount\").value);\n            const fromUnit = document.getElementById(\"fromUnit\").value;\n            const toUnit = document.getElementById(\"toUnit\").value;\n            \n            if (isNaN(amount)) {\n                document.getElementById(\"result\").innerText = \"Ingresa un n\u00famero v\u00e1lido\";\n                return;\n            }\n\n            \/\/ Convertir a gramos primero (unidad base)\n            let grams;\n            switch (fromUnit) {\n                case \"g\": grams = amount; break;\n                case \"kg\": grams = amount * 1000; break;\n                case \"lb\": grams = amount * 453.592; break;\n                case \"oz\": grams = amount * 28.3495; break;\n            }\n\n            \/\/ Convertir de gramos a la unidad deseada\n            let result;\n            switch (toUnit) {\n                case \"g\": result = grams; break;\n                case \"kg\": result = grams \/ 1000; break;\n                case \"lb\": result = grams \/ 453.592; break;\n                case \"oz\": result = grams \/ 28.3495; break;\n            }\n\n            const resultText = `${amount} ${getUnitName(fromUnit)} = ${result.toFixed(4)} ${getUnitName(toUnit)}`;\n            document.getElementById(\"result\").innerText = resultText;\n            document.getElementById(\"resultValue\").value = result.toFixed(4);\n            addToHistory(resultText);\n        }\n\n        \/\/ Intercambiar unidades\n        function swapUnits() {\n            const fromUnit = document.getElementById(\"fromUnit\");\n            const toUnit = document.getElementById(\"toUnit\");\n            [fromUnit.value, toUnit.value] = [toUnit.value, fromUnit.value];\n            convertAuto();\n        }\n\n        \/\/ Copiar resultado al clic\n        function copyResult() {\n            const resultInput = document.getElementById(\"resultValue\");\n            navigator.clipboard.writeText(resultInput.value);\n            resultInput.classList.add('copied');\n            setTimeout(() => resultInput.classList.remove('copied'), 1000);\n        }\n\n        \/\/ Copiar historial completo\n        function copyHistory() {\n            const historyItems = Array.from(document.querySelectorAll('#historyList li')).map(li => li.textContent);\n            navigator.clipboard.writeText(historyItems.join('\\n'));\n            alert('Historial copiado!');\n        }\n\n        \/\/ Obtener nombre de unidad\n        function getUnitName(unit) {\n            return { \"g\": \"g\", \"kg\": \"kg\", \"lb\": \"lb\", \"oz\": \"oz\" }[unit];\n        }\n\n        \/\/ Historial (localStorage)\n        function addToHistory(text) {\n            let history = JSON.parse(localStorage.getItem('weightHistory') || '[]');\n            history.unshift(`${text} (${new Date().toLocaleTimeString()})`);\n            if (history.length > 5) history.pop();\n            localStorage.setItem('weightHistory', JSON.stringify(history));\n            loadHistory();\n        }\n\n        function loadHistory() {\n            const history = JSON.parse(localStorage.getItem('weightHistory') || '[]');\n            document.getElementById(\"historyList\").innerHTML = history.map(item => `<li>${item}<\/li>`).join('');\n        }\n\n        function clearHistory() {\n            localStorage.removeItem('weightHistory');\n            loadHistory();\n        }\n    <\/script>\n","protected":false},"excerpt":{"rendered":"<p>\ud83c\udf19 Gramos (g)Kilogramos (kg)Libras (lb)Onzas (oz) \u2194\ufe0f Kilogramos (kg)Gramos (g)Libras (lb)Onzas (oz) Historial \ud83d\udccb Limpiar Historial<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-23","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Conversor de Peso - Veirax Web Tools<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Conversor de Peso\" \/>\n<meta property=\"og:description\" content=\"\ud83c\udf19 Gramos (g)Kilogramos (kg)Libras (lb)Onzas (oz) \u2194\ufe0f Kilogramos (kg)Gramos (g)Libras (lb)Onzas (oz) Historial \ud83d\udccb Limpiar Historial\" \/>\n<meta property=\"og:url\" content=\"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/\" \/>\n<meta property=\"og:site_name\" content=\"Veirax Web Tools\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-17T08:23:49+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/\",\"url\":\"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/\",\"name\":\"Conversor de Peso - Veirax Web Tools\",\"isPartOf\":{\"@id\":\"https:\/\/veiraxweb.com\/herramientas\/#website\"},\"datePublished\":\"2025-04-17T08:02:54+00:00\",\"dateModified\":\"2025-04-17T08:23:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/veiraxweb.com\/herramientas\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Conversor de Peso\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/veiraxweb.com\/herramientas\/#website\",\"url\":\"https:\/\/veiraxweb.com\/herramientas\/\",\"name\":\"Herramientas\",\"description\":\"Herramientas \u00fatiles online y gratis\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/veiraxweb.com\/herramientas\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Conversor de Peso - Veirax Web Tools","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"es_ES","og_type":"article","og_title":"Conversor de Peso","og_description":"\ud83c\udf19 Gramos (g)Kilogramos (kg)Libras (lb)Onzas (oz) \u2194\ufe0f Kilogramos (kg)Gramos (g)Libras (lb)Onzas (oz) Historial \ud83d\udccb Limpiar Historial","og_url":"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/","og_site_name":"Veirax Web Tools","article_modified_time":"2025-04-17T08:23:49+00:00","twitter_card":"summary_large_image","twitter_misc":{"Tiempo de lectura":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/","url":"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/","name":"Conversor de Peso - Veirax Web Tools","isPartOf":{"@id":"https:\/\/veiraxweb.com\/herramientas\/#website"},"datePublished":"2025-04-17T08:02:54+00:00","dateModified":"2025-04-17T08:23:49+00:00","breadcrumb":{"@id":"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/veiraxweb.com\/herramientas\/conversor-de-peso\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/veiraxweb.com\/herramientas\/"},{"@type":"ListItem","position":2,"name":"Conversor de Peso"}]},{"@type":"WebSite","@id":"https:\/\/veiraxweb.com\/herramientas\/#website","url":"https:\/\/veiraxweb.com\/herramientas\/","name":"Herramientas","description":"Herramientas \u00fatiles online y gratis","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/veiraxweb.com\/herramientas\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"}]}},"_links":{"self":[{"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/pages\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":3,"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/pages\/23\/revisions"}],"predecessor-version":[{"id":29,"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/pages\/23\/revisions\/29"}],"wp:attachment":[{"href":"https:\/\/veiraxweb.com\/herramientas\/wp-json\/wp\/v2\/media?parent=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}